Hacker News new | ask | show | jobs
by mschuster91 2209 days ago
> P.S. Why the trailing slash on the tag? It’s completely useless, by definition, and trailing slashes can mislead people into thinking that you can close tags that way, which you can’t.

Simple: so that XML parsers can load the HTML, as they are not aware of the HTML context which allows "unclosed" tags.

1 comments

You wouldn’t parse an HTML document with regular expressions.

So why would you parse one with an XML parser? It’s just wrong. (And an effort doomed to failure if you ever have to deal with documents other people wrote, because very few will parse.)

I deal with boatloads of manually written XML and HTML (templates) at my job. It's simpler in mindset to always write something that can be parsed as XML and is not much overhead (a single byte ffs).
There are a lot of more XML parser than HTML5 parser in the world. That's an argument for polyglot markup, if you like the open web and HTML as an API.