The Great HTML Debate
March 9th, 2009 - Web DevelopmentComments (2)

The original focus for this post was to discuss the advantages and disadvantages of validating your website. However, Jeff Atwood at Coding Horror has just recently visited this topic in a well thought out post – which I believe covers it nicely. Take a look at the comments as well for more points of discussion, including how a valid site may help with Google rankings.
Instead this post will be devoted to discussing the topics of XHTML vs. HTML, and Strict vs. Transitional doctypes.
A substantial portion of modern sites are built using the XHTML doctype. But beyond being the default doctype of many web IDEs, is there an advantage to using it?
The Differences
HTML is derived from SGML, while XHTML is dervied from both HTML and XML – resulting in a more structured language. This also produces the following differences from HTML:
- Tag and attribute names must be written in lower case
- Elements must be nested
- Tags must be closed
- Empty elements must be terminated
- Attribute values must be quoted
- Attribute value pairs must be expanded
What does this mean when creating sites?
Well, your documents may end up being well-formed ( if you create a valid XHTML document ), and the resulting code neater. Some argue that it will also become more future proof as XML becomes more prevalent.
For compatibility purposes the majority of XHTML websites are rendered using the HTML media type (text/html), as opposed to the official media type for XHTML (application/xhtml+xml). Even though many browsers are compatible with the application/xhtml+xml media type, IE is not. So since sites are not rendered as XML, what are we missing out on?
- The ability to define a custom markup language, able to code documents more precisely
- Better searching and navigation of documents with better structure and semantics
- Namspaces
- Faster parsing
Day to day web creators probably won’t even notice these missing from their product, though they seem nice. Also, the cleanliness and order that XML enforces can be implemented by an attentive coder into HTML.
Strict vs. Transitional
“This is HTML 4.01 Strict DTD, which excludes the presentation attributes and elements that W3C expects to phase out as support for style sheets matures. Authors should use the Strict DTD when possible, but may use the Transitional DTD when support for presentation attribute and elements is required.”
HTML 4 Document Type Definition
HTML and XHTML both offer the ability to code using a Strict or Transitional doctype ( Frameset as well, but we’ll focus on these two for today ). The Strict doctype enforces the separation of design and content that the introduction of CSS enabled. Transitional doctypes were introduced to ease legacy sites into the new age. The differences between the Transitional and Strict doctype for an XHTML page can be viewed here.
There are still a significant number of sites emerging that use the Transitional doctype. Large legacy systems may encounter problems shifting to the Strict doctype, but new sites should not encounter these problems. Of course some features that web creators may rely on, such as the target attribute for links, have been removed – workarounds do exist.
Now it may seem like more work to use a workaround when you can simply continue to use the Transitional doctype, however, using the Strict doctype does have its advantages. Due to the tighter restrictions placed on the coder, cross browser compatibility issues are reduced. This can often save time when creating sites that required cross browser compatibility. It will also reinforce the separation of design and content, allowing your site to be more flexible in the future, making redesigns and modifications far easier.
What’s next?
With new flavors of HTML on the horizon it will be interesting to see which direction the web will flow. The web is becoming more interactive and rich with media content pushing the boundaries everyday, but HTML will still play an important part – best to know what’s out there before the next wave hits.
Nice post! I wonder if there are significant differences in javascript execution speeds, or whether libraries like jquery and mootools are better optimized for XHTML? Seems like it would have higher performance for mobile devices, perhaps “transitional” unwinds that though?
Seems like a possible future post! I’m not sure if there would be a significant advantage right now, since most XHTML documents are rendered using the HTML DOM, but to compare it to an XML DOM would be interesting.