Certain elements don't need to have a closing tag; it's implied, and the browser closes it for you. From the html spec, the following tags don't need to be closed:
- html (if
</html> is not meant to be immediately followed by a comment)
- head (if
</head> is not meant to be immediately followed by whitespace or a comment)
- body (if
</body> is not meant to be immediately followed by a comment)
- li (if the
li element is immediately followed by another, or if it's the last child of its parent)
- dt (if the
dt element is immediately followed by another, or by a dd)
- dd (if the
dd element is immediately followed by another, by a dt, or if it's the last child of its parent)
- p (if the
p element is immediately followed by any of a long list of elements, or if it's the last child of its parent and that parent is not a, audio, del, ins, map, noscript, or video)
- rt (if the
rt element is immediately followed by another, by a rp, or if it's the last child of its parent)
- rp (if the
rp element is immediately followed by another, a rt, or if it's the last child of its parent)
- optgroup (if the
optgroup element is immediately followed by another, or if it's the last child of its parent)
- option (if the
option element is immediately followed by another, by an optgroup, or if it's the last child of its parent)
- colgroup (if
</colgroup> is not meant to be immediately followed by whitespace or a comment)
- caption (if
</caption> is not meant to be immediately followed by whitespace or a comment)
- thead (if the
thead element is immediately followed by a tbody or tfoot)
- tbody (if the
tbody element is immediately followed by a thead, tfoot, or if it's the last child of its parent)
- tfoot (if the
tfoot element is the last child of its parent)
- tr (if the
tr element is immediately followed by another, or if it's the last child of its parent)
- td (if the
td element is immediately followed by another, a th, or if it's the last child of its parent)
- th (if the
th element is immadiately followed by another, a td, or if it's the last child of its parent)
The tag-pair rule can't enforce tag pairs for elements that require being paired, while allowing optional closing tags. It's all or nothing. Even just being able to provide exceptions (similar to attr-lowercase) would be useful.
Certain elements don't need to have a closing tag; it's implied, and the browser closes it for you. From the html spec, the following tags don't need to be closed:
</html>is not meant to be immediately followed by a comment)</head>is not meant to be immediately followed by whitespace or a comment)</body>is not meant to be immediately followed by a comment)lielement is immediately followed by another, or if it's the last child of its parent)dtelement is immediately followed by another, or by add)ddelement is immediately followed by another, by adt, or if it's the last child of its parent)pelement is immediately followed by any of a long list of elements, or if it's the last child of its parent and that parent is nota,audio,del,ins,map,noscript, orvideo)rtelement is immediately followed by another, by arp, or if it's the last child of its parent)rpelement is immediately followed by another, art, or if it's the last child of its parent)optgroupelement is immediately followed by another, or if it's the last child of its parent)optionelement is immediately followed by another, by anoptgroup, or if it's the last child of its parent)</colgroup>is not meant to be immediately followed by whitespace or a comment)</caption>is not meant to be immediately followed by whitespace or a comment)theadelement is immediately followed by atbodyortfoot)tbodyelement is immediately followed by athead,tfoot, or if it's the last child of its parent)tfootelement is the last child of its parent)trelement is immediately followed by another, or if it's the last child of its parent)tdelement is immediately followed by another, ath, or if it's the last child of its parent)thelement is immadiately followed by another, atd, or if it's the last child of its parent)The
tag-pairrule can't enforce tag pairs for elements that require being paired, while allowing optional closing tags. It's all or nothing. Even just being able to provide exceptions (similar toattr-lowercase) would be useful.