Sean of Elementary Group Standards asked me, as part of a CSS Spring Reboot 2006 questionnaire, why I used HTML 4. Was using HTML instead of xHTML a concious choice on my part? Absolutely.
While the other people who were questioned managed to keep it nice and concise, I managed to write up a whole bucket load of words about it. As others asked me why I made sure Bite Size Standards is HTML 4, I’ve decided to post my answer here too.
“I’ve used xHTML for 5 years, from 2001 til 2006. My original reason for using it was that it is supposed to be the future. It would have benefits like in-line SVG and MathML. It was presented as TheThingToUse(tm) with CSS.
There are two things about xHTML which make it a poor choice for (public) sites. Both of them have to do with xHTML’s mime-types. In short, xHTML can be sent with text/html or application/xhtml+xml as the mime-type. On the web xHTML is usually sent as text/html, as Internet Explorer (which has 83+% market share) doesn’t support the other mime-type. Both mime-types are valid for xHTML 1.0, but (supporting) browsers do handle them differently.
It’s the handling of the same code differently where xHTML’s problem lies. When xHTML 1.0 is sent as text/html, it is handled as HTML. This means that it has zero user benefits over HTML 4.01.
When sent as application/xhtml+xml, you could use MathML – but – the browsers will also apply draconian error handling. This way users visiting the site will be punished (by not being able to see the site) for mistakes by the creator (which could be the developer, the CMS, the person updating the text or indeed the user her/himself just writing something). Simple things like a misplaced “
&” on a page (instead of “
&“) will completely shut off a page from its users.
So not only are there no benefits over HTML 4.01 because you have to send Internet Explorer text/html – you do get user-punishing error handling from other browsers if you decide to send to them the application/xhtml+xml mimetype.
No benefits but increased headaches? Mwa, count me out.
Some people might say ‘but xHTML is the future!’ This may well be, but is of little consequence. The future versions of xHTML (1.1 and 2.0) are not backwards compatible with xHTML 1.0, so writing xHTML now gains you little in the future. Furthermore HTML 5 is coming. Who says that can’t be the future?
My recommendations for writing HTML? Use the doctype ‘HTML 4.01 Strict’ and write your code as xHTML compatible as possible. This means self-closing tags in the body, but not in the head.*
*Little known fact: It’s actually in the spec that you’re not allowed to self-close the meta or link tags. Quite silly in practical terms, and I would suggest to the HTML 5 people that they change that[1. And lo and behold they did! In HTML 5 it’s completely up to you whether you self-close tags or not.].
I hope this answers all the questions people have, but if you have any more (or dare to question my arguments!) don’t hesitate to use the comment form accompanying this journal entry.