WordPress.org

Ready to get started?Download WordPress

Forums

[resolved] Generated p before img (3 posts)

  1. fjpoblam
    Member
    Posted 1 year ago #

    My posts often begin, simply, with an 'img'. The loop in my template to display a post contains, simply, the usual 'php the_content...' . Upon viewing the source online, I find that WordPress has inserted a 'p' in front of the 'img'. (And, FWIW, the 'p' is never closed.) In addition to producing invalid HTML, this insertion yields difficulty in my CSS. (I would like to style the first paragraph of each post in a slightly larger font, and all but the first paragraph text-indented.) How may I avoid insertion of this 'p'? My site is http://fjpoblam.com

  2. Andrew
    Forum Moderator
    Posted 1 year ago #

    Can you provide an example of the issue where the paragraph is generated around the image but not closed?

    Inline elements are automatically wrapped in block elements by WordPress.

    Are you satisfied with wrapping a <div> element around your image? This way a <p> element will not be wrapped.

  3. fjpoblam
    Member
    Posted 1 year ago #

    I wasn't aware that inline elements are automatically wrapped. I'll edit my posts and wrap them. Thank you for the information! That surely solves my problem (or answers my question, as it were.) It is to be noted that an unwrapped inline element is valid HTML (according the W3C validator, at any rate) and may be styled successfully. However, I write my posts in valid HTML, and so I'll take care to accommodate WP in advance. Thanks again. (Marked as resolved.)

Topic Closed

This topic has been closed to new replies.

About this Topic