A/

/ HTML or XHTML: A purist’s dilemma

Whenever possible, I like to do things the right way. Proper implementation of anything—though it may take more effort initially—returns dividends in the form of higher performance, reliability, scalability, re-usability, and so on and so forth. This principle applies to life in general and isn’t limited to web development (read: Tacoma Narrows Bridge). It is however at the core of this article and the focus of the issue I am wrestling with.

For some time now, I was under the impression that XHTML was simply “better HTML,” due to its inherent well formedness—what with it being written in XML and all. But it seems I was mistaken (and I’m willing to admit it). Recently I’ve been reading articles by Anne van Kesteren, and it’s gotten me wondering if I didn’t just jump on the XHTML bandwagon without even asking myself that one all-important question: “Do I really need this?” Had I taken the time to explore the issue a little, I would have found out that in order to deliver XHTML to a client properly, I should be doing it via the application/xhtml+xml MIME type. Currently my documents are delivered as text/html, so all I have to do is change the MIME type right? Not really. While Firefox supports it, IE doesn’t. A document delivered to IE using the application/xhtml+xml MIME type causes the browser to display a download window as it doesn’t support it as a known document format. I could rig my web server to deliver the document in text/html for IE, but then I’d have to ask myself: “Is the effort worth it?” In other words, what advantage would XHTML bring me for the effort I’d have to expend in properly implementing it? Not to mention the fact that it would still be delivered in the incorrect MIME type in IE. The answer unfortunately is: none. Though there really aren’t any major semantic differences between HTML and XHTML, I’d really only need to use the latter if I had to extend HTML with MathML or some other custom markup languages. For more on this, read Anne’s post entitled: “MIME types matter; DOCTYPEs don’t

Now, some of you may be thinking “big deal, it still validates as XHTML even if the MIME type says it’s HTML and not XHTML.” Well, that would be a bad assumption to make since according to the W3C HTML WG Chair Steve Pemberton, …documents served as text/html should be treated as HTML and not as XHTML. This means that even though I work very hard at writing properly formed XHTML, in reality what I’ve been doing is exactly what I’ve been trying hard to avoid: I’ve been writing tag soup! That’s right, since in essence I’ve been delivering HTML documents using mal-formed HTML.

My dilemma is the following: Do I switch to HTML 4.01 and get used to uppercase tags that don’t self-close? Do I stay with XHTML 1.0 Strict and keep delivering it with the incorrect MIME type? Do I rig Apache to deliver my XHTML with the application/xhtml+xml MIME type and abandon visitors with older browsers (like IE 6). Or do I find a happy medium that delivers application/xhtml+xml to conforming browsers and text/html to everyone else?

What do you think?

–30–

Read more from the archive.