Remove P tags from images (9 posts)

  1. gavinhallweb
    Posted 7 years ago #

    I cannot solve this one alone.

    Using web editor or MarsEdit, regardless of how i input the content into a new blog post, the following happens:

    I paste:
    <img src="WHATEVER" /><p>SOME CONTENT</p>

    And its translated into:
    <p><img src="WHATEVER" /></p><p>SOME CONTENT</p>

    So it assumes the image needs to be wrapped into a paragraph tag. I want to explicitly declare the difference in CSS between an img and a paragraph. Ive tried the advanced editor but doesnt help.

  2. MichaelH
    Posted 7 years ago #

    @gavinhallweb - deleted your duplicate threads.

  3. gavinhallweb
    Posted 7 years ago #

    Ok - surprised that no-one knows it tho as other designers must run straight into this one every time.

  4. gavinhallweb
    Posted 7 years ago #

    I half fixed by wrapping the whole entry in a div - not great but works.

  5. nintensity
    Posted 7 years ago #

    Hi there! I would like to know how to do this as well.
    Can anyone help the OP as well as me?

    I'm actually trying to give the P tag that is wrapped around the img tag a class attribute. Is this possible?



  6. spence88mph
    Posted 7 years ago #

    I've searched high and low for a solution for this.

    If someone can do it I'll pay them, very frustrating!!

    I know there is a plug-in that strips the <p> tags from everything, just want it to strip them from the images! I also know the div trick but it's not user friendly for a client.



  7. straydog
    Posted 7 years ago #


    This removes it from paragraphs as well though. I suggest you make a css element in which p img { margin: 0; } ?

  8. cfheinen
    Posted 6 years ago #

    One solution is through the use of JQuery's :has selector. It will allow you to look for paragraphs that contain <img>. This should do the trick:

    $("p:has(img)").css('margin' , '0');

    Check out this link for more info.


  9. cfheinen
    Posted 6 years ago #

    I elaborate further on how to use jQuery to solve this problem on my blog.


Topic Closed

This topic has been closed to new replies.

About this Topic