WordPress.org

Support

Support » How-To and Troubleshooting » WP adds paragraph tags to images

WP adds paragraph tags to images

  • I’m troubleshooting why WP adds paragraph tags to my html code for images. I’m sure others have experienced this, I just can’t find any relevant posts on this topic. Could anyone point me in the direction of an explanation for this phenomenon? Site reference: http://www.moonfireandsun.com

    It’s frustrating when an application changes or adds to your code without any warning. It causes the pages to fail validation. Much thanks.

Viewing 5 replies - 1 through 5 (of 5 total)
  • whooami

    @whooami

    Member

    you are talking about the opening and closing <p> tags around your images?

    Because the IMG element is an inline element, not a block element, and it cannot be in the page unless it is inside block level tags.

    This:

    <p> Stuff </p>
    <img src="whatever" />
    <p> more stuff </p>

    Is invalid HTML. Has been since at least HTML 4.0. You have to put the IMG inside a P or a DIV or something. It must be inside a block, or it’s invalid code.

    The validation error on your page is not that img is inside a p, it’s that the p is not closed before the h3 starts. Wrap your imgs in divs or p’s to correct the problem.

    whooami

    @whooami

    Member

    How, specifically, are you adding your images?

    Are you writing the <img src=... into the post textbox? If so, are you using the code tab or the visual tab?

    If you are using the code tab, are you using the image quicktag button?

    Or are you using the the upload function on the posting screen?

    whooami

    @whooami

    Member

    nm my posts, otto is better 🙂

    Can’t believe I missed that one. That indeed fixed it. You guys were a lot of help. Much thanks!

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘WP adds paragraph tags to images’ is closed to new replies.
Skip to toolbar