logoalt Hacker News

kbolinoyesterday at 3:44 PM2 repliesview on HN

A lot of HTML tags never have a body, so it makes no sense to close them. XML has self-closing tag syntax but it wasn't always handled well by browsers.

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.


Replies

afavouryesterday at 4:01 PM

> 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.
show 1 reply
Pxtlyesterday at 4:05 PM

> 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.

https://xkcd.com/927/

show 2 replies