HTML vs. XHTML

Back when I first heard of XHTML it seemed like a brilliant idea. Here was a type of mark-up with rules, and rules mean an excuse to be my normal perfectionist self. It wasn’t long before I’d converted all 200+ pages of my website to this beautiful, lower-case, tidy syntax and was getting the green light from the validator. However, nobody told me why I should be using XHTML or gave a reason for switching much beyond “XML, and thus XHTML, are the way of the future!”

These days whether or not I use XHTML or HTML depends entirely on which DTD I can remember how to spell first, because the superiority of either is entirely subjective. There is no straight answer from the experts on which should be used, and with enthusiasts on both side of the fence piping theirs as the best it’s almost tempting to flip a coin and go with the flow.

On one hand, we are advised that XHTML delivered as text/html (to make it work in Internet Explorer) is “broken” and incorrect. This is hardly disputable — it makes sense that XHTML should be delivered as application/xhtml+xml — however there seems to be little or no evidence on any dramatic difference that this has on the browser or the reader. My “tag soup” may be served on a dented copper plate to the browser, but Google has no problem indexing it as if it were eating off fine bone china. (Lamest metaphor ever!)

It is argued that XHTML as text/html might work now, but what about when you change it to application/xhtml+xml?! Did these experts consider that tag soup fans might not want to serve their pages any differently in the future and therefore their point is redundant?

However, if HTML does everything that XHTML can — which it does — is there any point in using anything but HTML? Surely by not having to self-close line breaks, image tags and the like, and by not having XML declarations/etc in the head of our documents we’re actually saving all important space and bandwidth? Furthermore, even if any self-respecting web geek avoids Internet Explorer like the plague, it doesn’t hurt to give it code it can properly process.

My personal conclusion is that the choice between XHTML and HTML is completely irrelevant. Whether or not you add little forward slashes to the end of tags is not going to make or break a website. The important thing is coding semantically, for validity and compatibility, whichever doctype you use. Choose a strict doctype over transitional, and give your browser the best mark-up you can deliver.

Comments are closed.