Alex Rivera | Logout

Should a heading be inside or outside a <p>?

Asked 2013-03-27T10:36:42.757
32

I have a div element and within that div, we have text between p elements.

I want to add a heading. Should it go inside or outside the p?

Which is better:

<p>This is text
    <h3>This is my h3</h3>
    More text
</p>
<p>another text<p>

or

<p>This is text<p>
<h3>This is my h3</h3>
<p>another text<p>
Edit
Report

1 Answer

5

According to standards a Paragraph should not contain other block elements (including paragraphs and headers). As indicated in other answers, to group a header with a paragraph you can use the div tag.

You can find a lot of information about this subject also on w3c's website: http://www.w3.org/TR/html401/struct/global.html#block-inline

answered 2013-03-27T10:54:00.950

Your Answer