One thing that may surprise readers of the book is my choice to use HTML4 Strict for the markup in the book. That may seem strange given that the last decade has been devoted towards pushing “web standards with XHTML.” After all, experts like Jeffrey Zeldman can’t be wrong, can they?
Of course not. At least not then. Zeldman and others took a gamble on XHTML, picked it up and ran with it. Zeldman taught many of us through his articles and books that semantic well-formed markup is right and good. Unfortunately, some technical problems came up in the last few years that most web developers who took Zeldman’s advice haven’t really paid attention to until recently.
XHTML is fundamentally broken thanks in large part to Microsoft Internet Explorer. Allow me to explain.
XHTML documents, in order to be read by Internet Explorer, have to be served as
text/html> which causes browsers to treat the page as HTML anyway. All those closing tags you added that you didn’t need to add get stripped out, and worse, self clsoing tags get removed.
The article “Beware of XHTML” shows some great examples of what can happen when you serve completely valid XHTML with the wrong content type. Here’s my favorite one:
You can visit the same page served with the correct content type of
application/xml+html, unless you’re on Internet Explorer, which will try to download the file instead of displaying it!
I’ve made the switch away from XHTML, and I urge you to do so as well. But don’t blindly follow anyone’s advice, experiment for yourself. One of the reasons XHTML has stuck around for so long is that developers, including myself, cargo-culted the advice and techniques of others without doing their own research. Stop that right now!
Besides, XHTML isn’t the future – HTML 5 is, and HTML 4.01 Strict documents have a better shot of forward compatibility. That sets you and me up quite nicely to embrace HTML 5 when it’s ready.