3 ms·
(non-trivially, and not always, granted) Note that <li> example is perfectly valid, and will be parsed correctly by any html5 capable parser. Per the html5 sp
by dsp1234 10y ago
(non-trivially, and not always, granted)
Note that <li> example is perfectly valid, and will be parsed correctly by any html5 capable parser. Per the html5 spec, the closing tag on an <li> element is optional.[0]
[0] - https://html.spec.whatwg.org/#optional-tags https://html.spec.whatwg.org/#optional-tags
An li element's end tag may be omitted if the li element is immediately followed by another li element or if there is no more content in the parent element.
- verandaguy 10y agoFair enough, TIL. I'd imagine it's much less valid if the missing closing `</li>` is on the first line, though.
- mbrock 10y agoNo, you can write the entire list without any </li> tags and it's perfectly fine. You also generally don't need to close your <p> tags to start a new paragraph, because paragraphs don't nest inside each other.
- dsp1234 10y agoThis is a perfectly valid html5 document: <!doctype html> <title></title> <ul> <li>item1 <li>item2 </ul>