130

I am trying to figure all the valid HTML5 elements that can be nested inside paragraph elements such that w3 validator doesn't show any errors. I mean I am trying to figure all tags that can replace the dots in the following code such that w3 validator doesn't show any errors:

<p>...</p>

Is there such a list available? I tried searching on Google without any luck.

Even if the converse list is available, i.e. elements that can not be nested inside paragraph elements, it is good enough for me.

0

1 Answer 1

178

The HTML spec tells us that the <p> element's content model is phrasing content. Phrasing content is defined by the spec:

3.2.5.2.5 Phrasing content

Phrasing content is the text of the document, as well as elements that mark up that text at the intra-paragraph level. Runs of phrasing content form paragraphs.

Sign up to request clarification or add additional context in comments.

7 Comments

Why does this validates correctly then on the validator page html5.validator.nu <p>Hello world<em>Test</em><img src="http://google.com/asd/cp" alt="Description"/></p>
@GabrielRodriguez I would expect that to validate. Why do you expect it not to?
ooops, sorry never mind, because I thought <img> was not on the list, but now I see it is. sorry.
I should point out that sub elements should also be on that list. For example, the <option> element is under the <select> element, so it should also be legal in between the <p> and </p>
Sub elements should not be on this list because this is a list only of elements allowed within <p> elements, not of elements that are allowed within elements that are allowed within <p> elements nor of elements that are allowed within elements that are allowed within elements that are allowed within <p> elements. If you want to know what's allowed with the elements listed, click the name of the element; it's a link to the definition of that element which has a list of the elements allowed within it.
|

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.