Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

Wow, I had no idea that `<div/>` wasn't interpreted as `<div></div>`.


Yeah it's been a while since I was really in the markup weeds but that surprised me also. Though now that I think about it, I think I have run into that trying to create an empty div, realizing I needed to write it as <div></div> and rolling my eyes at the "inconsistency"


I'm pretty sure it was interpreted like that, at least in IE in the XHTML days. Between the end of the XHTML era and the beginning of HTML5 they formalized the distinction between self-closing and non-self-closing tags like <div> and <br/>. I think that was a mistake.


You misremember—it’s the other way around. IE never supported self‐closing arbitrary elements, because IE never supported rendering an (X)HTML page using an XML parser.

Requiring the slash to self‐close, and allowing any element to be self‐closed, were features of XML that never existed in HTML. When XHTML came around, rendering it required an XML‐capable parser, signaled by the webserver serving the page with the application/xhtml+xml MIME type instead of type/html. Doing so came with a slew of other effects required by XML like hard‐erroring when markup was not well‐formed.

This was a big change for both browsers and web designers, so the XHTML 1.0 spec featured a compatibility mode: since XHTML 1.0 was essentially a one‐to‐one representation of HTML 4 elements as XHTML elements, XHTML documents could be rendered with a plain HTML parser, so long as they followed various rules to look like an HTML page, such as self‐closing only elements that are self‐closable in plain HTML. To incentivize people to move to the new MIME type, the W3C made this compatibility allowance temporary and removed it from the next version, XHTML 1.1.

Of course, the consequence was inevitable. Effectively nobody used XHTML 1.1, and effectively nobody used application/xhtml+xml. W3C’s insistence on promoting breaking compatibility with the overwhelming majority of the web led to its loss of control of the HTML specification to WHATWG, a coalition of browser vendors. W3C’s nascent XHTML 2.0 withered and died, and WHATWG’s desired vision for HTML5 became the new standard de jure, not just de facto.


Me neither, possibly because JSX, Svelte etc. do actually interpret it that way, deviating from HTML.


Me neither. I was so ready to disagree with the article, but this kinda won me over.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: