HTML or XHTML? Which is right?
Friday, July 10th, 2009
In recent days, there has been much talk about the future of HTML and XHTML, following the announcement that the work on XHTML2 is going to be wrapped up. I’ll not re-hash what everyone else has said here, instead I’ll simply refer you to Jeffrey Zeldman and Jeremy Keith’s respective posts.
Shortly after this all happened, I received this email from a prospective buyer:
I’ve been interested in your book for a while, and checked out SitePoint’s free sample chapters. I noticed before much else that you use XHTML. I’m wondering if you’ll be coming out with a third edition using HTML 5 now that XHTML 2 has been dropped in favour of HTML 5.
To which I would like to say:
The demise of XHTML2 does not mean that XHTML1 is, by the same notion, not fit for purpose.
Some web developers prefer to use HTML4, others prefer XHTML1 while others are investigating and/or tentatively using HTML5. HTML5 is still something of a moving target, while HTML4 and XHTML1 are well-defined, stable and well-established specifications. You are free to choose whatever you wish, just do it right (follow that language’s rules, e.g. do you need to have lowercase tags? Should tags be closed? Are attribute values quoted or not?).
In my book, I teach with XHTML1. Among the reasons for doing this are:
- The rules are a bit more rigid but they are consistent – this is better for new people learning, in my opinion. No shortcuts to learn
- If you learn XHTML syntax, it’s arguably easier to transition back to writing valid HTML4 than it is to do it the other way around
- The issue of serving the XHTML with the correct MIME type is so ridiculously above the level of knowledge that a beginner should be expected to know that it’s best not touched upon, lest it confuse the heck out of the reader. There is little point in making the reader sweat the small stuff rather than just letting them get on and learn (in an earlier draft, there was an advisory note to this end, but in the review stage we all felt it was best to cut out)
- SitePoint wanted/preferred it. From a marketing point of view, XHTML is an easier one to sell, as it’s a newer spec; some people might (mistakenly) think that learning HTML4 is not appropriate or fresh enough, so I can easily understand why the publishers prefer this
XHTML1 is still appropriate to teach, the demise of XHTML2 has no effect on this at all. So, if you were having second thoughts about this book, as the person who wrote this email did, please don’t worry – I’ll still be teaching you how to build your site the right way!
