0 votes
1 view
in Web Technology by (22.4k points)

Which is standard-compliant between these two?

<p>Text text text ...

    <ol>

        <li>First element</li>

    </ol>

</p>

<p>

    Other text...

</p>

OR

<p>

    Text text text ...

</p>

<ol>

    <li>First element</li>

</ol>

<p>

    Other text text ...

</p>

1 Answer

0 votes
by (66.4k points)

The second. The first is invalid.

  • A paragraph cannot contain a list.
  • A list cannot contain a paragraph but only if the paragraph is contained entirely within a single list item.

A browser will handle it like so:

<p>tetxtextextete 

&lt;!-- Start of paragraph --&gt;

<ol>

&lt;!-- Start of ordered list. Paragraphs cannot contain lists. Insert </p> --&gt;

<li>first element</li></ol>

&lt;!-- A list item element. End of list --&gt;

</p>

&lt;!-- End of paragraph, but not inside paragraph, discard this tag to recover from the error --&gt;

<p>other textetxet</p>

&lt;!-- Another paragraph --&gt;

If you are interested to learn Web Development, then enroll in this Web Development Online Course by Intellipaat.

Welcome to Intellipaat Community. Get your technical queries answered by top developers !


Categories

...