• WP is auto inserting <p> tags around my <img> tags – why? Not only is this shifting a unwanted line space at the top of the paragraph of text, but it’s also un-semantic.

    I’m aware of a plug in that removes all <p>’s from a post but it removes ALL <p> tags which I don’t want to happen.

    Anyone know where in the source code I can fix this daft error?

Viewing 4 replies - 1 through 4 (of 4 total)
  • Why are <p> tags around images un-semantic? <img> is an inline element and, therefore, the specs dictate that it must be enclosed in a block level element such as <div>. Or <p>. If you use the HTML tab and want to stop <p> tags being inserted, simply surround your image markup with <div> tags.

    If the extra space is bothering you, you can always wrap your image in your own <p></p> tags and give the <p> a class, then use CSS to remove any top padding/margin.

    Thread Starter johnasp

    (@johnasp)

    OK wrapping DIV around the images did the trick. Thanks guys.

    my code is as follows:

    <div>
    <img>MY IMAGE HERE</img>
    <p>MY PARAGRAPH HERE<p>
    </div>

    but wordpress changes this to

    <div>
    <p><img>MY IMAGE HERE</img><p>
    <p>MY PARAGRAPH HERE<p>
    </div>

    I don’t want those <p> tags around my image, is there a way to disable this auto insertion? thanks

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘I want to remove <p> tages WP is auto insterting around images’ is closed to new replies.