3 ms·
During the W3C’s period of… lesser judgment, they hoped to fight the plague of invalid HTML markup that dominated the Web by migrating everybody to XML, which u
by anjbe 5y ago
During the W3C’s period of… lesser judgment, they hoped to fight the plague of invalid HTML markup that dominated the Web by migrating everybody to XML, which unlike HTML with its extremely generous error handling, simply aborts upon any parse error. For example, Firefox’s “Yellow Screen of Death”: https://commons.wikimedia.org/wiki/File:Yellow_screen_of_death.png https://commons.wikimedia.org/wiki/File:Yellow_screen_of_dea...
For this to happen, a webpage has to be served with an XML Content-Type by the server—specifically, application/xhtml+xml. HTML documents are served with a Content-Type of text/html. If you write a page entirely in valid XHTML markup, but serve it with an HTML media type, the browser treats it not as XML, but as invalid HTML, like any other tag soup, and turn it into something approximating what you meant.
However, some browsers couldn’t handle application/xhtml+xml, and would simply prompt a download dialog for the page rather than displaying it. Well, one browser did that. You know the one… Internet Explorer. Because support for the new media type wasn’t widespread, the W3C allowed serving XHTML 1.0 pages as text/html as a transitional mechanism. They wouldn’t get any of the “benefits” of XML parsing (like the YSOD), but they’d display in IE. XHTML 1.1 and the stillborn 2.0 were required to be served as application/xhtml+xml, and thus saw only the barest minimum of adoption. As transitional mechanisms are wont to do, XHTML 1.0‐as‐text/html stuck around, W3C’s reputation took a blow, and WHATWG seized the reins, codifying browser practices into what’s now known as HTML5.
Incidentally, this is the origin of the space everybody puts within a self‐closing tag. An XML parser would see no difference between “<br/>” and “<br />”, but some tag soup HTML parsers of the time did. The XHTML spec had an appendix dedicated to these compatibility tricks that were solely needed because people were serving pages with the only Content-Type that IE understood. https://www.w3.org/TR/xhtml1/#guidelines https://www.w3.org/TR/xhtml1/#guidelines
- stan_rogers 5y ago<br/> is an illegal/invalid tag in HTML. The space makes the slash into a simple invalid attribute of a br element, which the browser can ignore.
- WorldMaker 5y agoThe HTML5 spec makes <br/> (without the space) valid in HTML5: https://dev.w3.org/html5/html-author/#void https://dev.w3.org/html5/html-author/#void Before that it was more "undefined" behavior than "illegal" as older HTML specs simply didn't consider it.