The End Tags You Can Skip
parser and markup 1995 still worksA li with no closing tag ends at the next li, and a p ends at the next p, because their end tags are optional.
In 2026: Still valid HTML. The standard lists p, li, dt, dd, tr, td, option and more as elements whose end tag may be omitted, and the parser closes each one when the next sibling or a block element starts. Three li lines with no closing tags parse as three separate items. A p cannot contain another p, so a second p tag closes the first.
Where it came from: The WHATWG HTML standard, Optional tags section. The habit goes back to hand-written HTML in the mid 1990s, before editors closed tags for you. WHATWG ↗
<ul>
<li>first
<li>second
<li>third
</ul>
<script>
document.write('<p>List items parsed: <b>' +
document.querySelectorAll('ul li').length +
'</b>. Each <li> closed itself at the next one.</p>');
</script>