Is it necessary to wrap <strong>, <em>, <b>, <i> inside <p> tag, if content is not paragraph?

Jitendra Vyas picture Jitendra Vyas · Feb 10, 2010 · Viewed 10.9k times · Source

For example:

This is ok

<div>
<p>some <strong>long</strong> text</p>
<strong>- end -</strong>
<p>some long text</p>
</div>

Or this is more semantically correct?

<div>
<p>some <strong>long</strong> text</p>
<p><strong>- end -</strong></p>
<p>some long text</p>
</div>

Answer

Quentin picture Quentin · Feb 10, 2010

If it isn't a paragraph, then it shouldn't be marked up as a paragraph. (The HTML specification explains how to read the DTD to determine what elements are allowed at a given point in a document.)

<p><strong>- end -</strong></p>

… however, I don't know what this is. You should follow the normal rules for grammar.