Sure I can try.
- You can’t use the p element as a container for the UL element, the UL element is a block-level element and it is not permitted as content inside the p element.
The P element represents a paragraph. It cannot contain block-level elements (including P itself).
- As you can tell by the screenshot, on the left I have selected the p element in the HTML box, on the right you can see how the browser is actually rendering the page (i.e. how the DOM looks). The empty p element you see highlighted in blue on the right is the p element selected in the HTML box.
- I believe what we are seeing is the result of the p element automatically closing as the browser encounters (parses) the UL block-level element, and so you end up with an empty p element.
Paragraphs are block-level elements, and notably will automatically close if another block-level element is parsed before the closing
</p>tag.
- In short, this is not valid HTML (Error: No p element in scope but a p end tag seen.):
<p>
<ul>
<li></li>
<li></li>
<li></li>
</ul>
</p>
This would be valid:
<div>
<ul>
<li></li>
<li></li>
<li></li>
</ul>
</div>
