Is XHTML worthwhile?
Let’s me nail my colours to the mast straight away: I use XHTML and have done so for several years. XHTML 1.0 has been a W3C recommendation for seven years (since January 2000). I’m aware of the well-argued objections by Ian Hixie, among others, against sending XHTML as text/html. Opponents of switching to XHTML 1.0 also point out quite rightly that XHTML 2.0 won’t be backwards compatible with previous versions.
So the arguments that break out in online forums from time to time about whether to use XHTML always tend to go over the same ground again and again: XHTML 1.0 isn’t really XHTML because it’s normally delivered using the wrong MIME type (text/html instead of application/xhtml+xml), and anyway everything’s going to change several years down the line when XHTML becomes the standard. My viewpoint has always been this:
- XHTML 1.0 is an official standard
- It’s fully supported by modern browsers (even Netscape 4 has no problems with it)
- Using XHTML 1.0 properly (in other words, making sure that it validates) teaches you the stricter standards that will be necessary when XHTML 2.0 eventually comes along (if it ever does)
- Well-formed XHTML makes it easier to work with CSS and dynamic code, such as PHP
Of course, you could use the same arguments about valid HTML 4.01. What matters most of all is that your code follows the rules and doesn’t rely on the forgiving nature of current browsers to cover up your mistakes.
This subject came up again a few days ago in the Dreamweaver forum. The discussion didn’t produce any real enlightenment, but it set me thinking. One of the arguments used in the past against adopting XHTML 1.0 is that “it doesn’t futureproof your site” because you’ll have to do everything again when XHTML 2.0 comes along. Then it struck me: that argument is completely wrong.
XHTML 1.0 is HTML 4.01 reformulated as XML. Since XML is designed to be machine-readable, it is futureproof. Pages designed with XHTML 1.0 may not be displayed by future browsers in the same way as XHTML 2.0, but the DOCTYPE will tell the XML parser how to read it. The same isn’t be true of HTML pages, even if they validate according to the 4.01 recommendation, because an XML parser will choke on empty elements, such as img tags.
6 comments January 2nd, 2007