Re:You are not required to close your <p>, <li>, <img>, or <...
by afavour on Sunday January 11, 2026 @11:01AM
(#46576840)
> A p or li tag, at least when used and nested properly, logically ends where either the next one begins or the enclosing block ends
While this is true I’ve never liked it.
<p>blah<p>blah2</p>
Implies a closing </p> in the middle. But <p>blah<span>blah2</p>
Does not. Obviously with the knowledge of the difference between what span and p represent I understand why but in terms of pure markup it’s always left a bad taste in my mouth. I’ll always close tags whenever relevant even if it’s not necessary.
Re:You are not required to close your <p>, <li>, <img>, or <...
by kbolino on Sunday January 11, 2026 @11:34AM
(#46577145)
This interpretation of the p element implies that it contains a paragraph. But HTML is first and foremost a document format, and one could just as logically conclude that the p element simply starts a new paragraph. Under the latter interpretation, </p> would never exist any more than </hr> or </img>.
In practice, modern HTML splits the difference with rigorous and well defined but not necessarily intuitive semantics.
Re:You are not required to close your <p>, <li>, <img>, or <...
by Pxtl on Sunday January 11, 2026 @11:05AM
(#46576880)
> XML has self-closing tag syntax but it wasn't always handled well by browsers.
So we'll add another syntax for browsers to handle.
Re:You are not required to close your <p>, <li>, <img>, or <...
by kbolino on Sunday January 11, 2026 @11:51AM
(#46577312)
I was going to respond that HTML was the original syntax and XML the usurper, but a comment in another thread casts some doubt on that version of events: https://news.ycombinator.com/item?id=46576844
A p or li tag, at least when used and nested properly, logically ends where either the next one begins or the enclosing block ends. Closing li also creates the opportunity for nonsensical content inside of a list but not in any list item. Of course all of these corner cases are now well specified because people did close their tags sometimes.