HTML vs. XHTML

Quite a while back I did a post on HTML document types. In that post I talked about how important it is to declare your document type to avoid quirks mode and random HTML rendering across browsers (i.e. spaghetti code).

At the time I was trying to standardize on using the XHTML strict specification in my code. Getting XHTML strict compliance in your code can be rather daunting. What you are essentially doing is making your code easier for a machine to read - you aren’t really doing a whole lot for yourself per se, and you are still essentially writing HTML. Still, XHTML seemed to be the ultimate successor to the HTML 4.x standard, so I thought I might as well start getting used to it.

Things are starting to shape up differently now, however. XHTML no longer seems to be the heir apparent to HTML, and a group consisting of many of the web browser developers/companies is actively working on a HTML 5.x standard. The main web browser companies are largely ignoring work on the XHTML 2.x spec.

Why this move away from XHTML? From the articles I’ve read, there are a number of reasons:

  • Today’s web browsers, virtually without exception, don’t parse XML - they’ll treat XHTML as regular HTML text. That isn’t changing any time soon, as most browser companies generally recommend against using XHTML (including Microsoft, Mozilla, Apple, and Opera). If you pass a special header forcing the browser to read your page as XHTML, Internet Explorer won’t even load the page.
  • XHTML 2.0 is not compatible with XHTML 1.x, a cardinal sin requiring you to rewrite all of your 1.x stuff. The HTML upgrades generally maintain backward compatibility, for better or for worse.
  • A lot of the benefits attributed to XHTML, upon inspection, are somewhat bogus.
    • You can do as much or as little content/presentation separation in HTML as you can in XHTML.
    • The source code isn’t necessarily any cleaner.
    • It doesn’t really speed things up even when using a browser that supports XHTML.
    • The whole XHTML is “extensible” bit only works if your browser supports it, and Internet Explorer probably never will.
    • You can close all of you HTML tags in standard HTML if you are absolutely dying to.
  • And the dagger in the back: writing clean XHTML is slow, laborious, and utterly unforgiving.
Starting now I’m going to make all my new web apps conform to the HTML strict specification rather than the XHTML specs unless some startling revelation comes along and flogs me about the head and neck. In a spec-war, I’m going to jump on the bandwagon of the software that actually uses the specs: browsers. And it looks like the major browser companies are shifting their support to HTML.

Have a different idea on XHTML vs HTML? Drop some feedback down below and let me know what you think.


Presuming the machine is an anal-retentive over-caffeinated perfectionist.