Back to the Konsensys

Back to Tips
Why Use Strict XHTML
by
George Van Treeck

I'll explain why I write these programming tip web pages using HTML 4, but chose to migrate the Konsensys DreamBeans tool to generating strict XHTML.

I use HTML 4 when I'm writing small and simple web pages like this one, because the minor mistakes I make like missing end tags, etc. still display okay, because browsers go into "quirks" mode when detecting minor errors and generally figure out my intentions and display a sufficiently correct page (FYI: IE is better at handling quirks than FireFox). Browsers run more slowly in quirks mode. But, the speed difference in quirks mode is too small to be visible because hand-written web pages are rarely so large and complex that that the slow down is visible.

The problem with HTML 4 is that it is ambiguous with different features implemented by different browsers or implemented in different ways and therefore often displays complex web pages differently on different browsers. Look at books on HTML 4 and a quarter of the thickness of the book is describing differences across browsers and which features of HTML 4 are supported by which browsers.

For simple web web pages HTML 4's ambiguity and spotty implementation isn't much of a problem. But for complex tables, etc. where exact alignment and appearance across all browsers is important, strict XHTML does a better job, because it is less ambiguous and browsers more fully implement all its features.

DreamBeans generates web pages that contain database-driven trees, simple tables, and a very complex XY tables. See the side-by-side product comparison tables on the BestPicker website for an example of an XY table. The table of side-by-side comparisons of compact digital cameras between $80 and $200 has about 5,000 table cells, with multiple fields in the row headers, column headers, and table cells. And the XY table has fancy scrolling capability that you may not have seen before. Strict XHTML helps that complex table display the same across browsers and display more quickly because the table is free of "quirks".

The Eclipse IDE displays warnings and errors in HTML files. Because strict XHTML is less ambiguous, it is easier for me to verify with strict XHTML in Eclipse so that I can be sure that DreamBeans is generating correct HTML. And if the HTML is free of quirks, then the browser displays more accurately across browsers, and runs more quickly, which can be noticeable on web pages containing very large tables or trees.

Also, sometimes there are tools or a feature that you very rarely need. But, when you need it, then you really need it. Suppose you want ship a large XML table of data to someone who might want to load that information into another database or report generator (e.g., display the table as a bar chart or graph). But, it would also be nice to view that same data in a browser. If you send the URL of a strict XHTML table, then the receiver can both display the data in a browser and possibly load the data into a database or report generator, because many database servers and report generators have built-in XML parsers for importing data.

But, with all that said, strict XHTML may wither away into oblivion because the new popular standard seems to be HTML 5. Already, there are large differences in what HTML 5 features are implemented across browsers. But, HTML 5 has new multimedia features. Sizzle sells...


Copyright (C) 2010 George Van Treeck. All rights reserved.