• Resolved fjpoblam

    (@fjpoblam)


    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

Viewing 2 replies - 1 through 2 (of 2 total)
  • Andrew Nevins

    (@anevins)

    WCLDN 2018 Contributor | Volunteer support

    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.

    Thread Starter fjpoblam

    (@fjpoblam)

    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.)

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Generated p before img’ is closed to new replies.