A blog post from danboe.net

Why choose valid XHTML over HTML?

Posted Aug 4, 2004 at 12:22 AM

When you sit down at the keyboard and approach a new implementation of something that will appear on the web, the most important piece to get right from the start is the markup. This post discusses why you should choose XHTML over HTML.

Why start with the markup?

  • Because it is most often generated via code, it’s harder to change than the separate and independent style and behavior files are.* Because it is most often not cached, it goes across the wire in its entirety with every response.
  • Because it defines the core experience, style and behaviors are simply optional that may or may not be there. We can’t require them, we have to accept that the enhancements are optional by definition.

Valid XHTML is, by definition, valid XML

  • Anything in valid XML can be parsed using one of the many different XML parsing methods out there, which makes it very easy to write some simple code to extract the content and convert it to something else.
  • Even better, you can use such parsing routines to validate and test the markup and content.

Imagine test having a suite of scripts that run to ensure the XHTML is valid, accessible and consistent in terms of guidelines as a part of the build process, before UI testers enter bugs.

Imagine automated tools that we can point at our pages to show us link counts, links that don’t use g, pages that don’t have a c-tag, etc.

Imagine being able to grab content from existing pages directly from the live pages themselves.

Imagine My MSN being able to add a summary of any page on the network as a module just by simply requesting and parsing the structure.

XHTML provides cleaner, more logical markup

XHTML brings uniformity to document structure. The rules of XHTML help restore the structural integrity of documents that was lost during the web’s rapid commercial expansion and browser wars of the 90’s.

XHTML provides increased interoperability

Unlike legacy HTML pages, valid, well-formed XHTML documents can in most cases be delivered without changes to wireless devices such as PDA’s, cell phones, Braille readers and other specialized web environments. Moreover, XHTML’s insistence on clean, rule-based markup helps us avoid the kind of errors that can make web pages fail even in current, state-of-the art browsers.

XHTML provides greater accessibility

Because they follow strict rules and avoid non-standard markup, well-authored XHTML pages are more accessible than legacy HTML pages, helping us comply with U.S. and International laws.

XHTML is generally lighter than HTML

There are several components to XHTML that result in reduced page weight, primarily:

  • Outdated and presentation-oriented tags and attributes are not defined in the schema, so they’re not in the XHTML. The markup is orientated around the semantic structure of the page, not the presentation.
  • Presentation is moved from markup to external, cacheable CSS.
  • One CSS positioned tag can replace many table, row and cell tag combinations.

XHTML renders faster than HTML in browsers

  • It’s simply more efficient to parse valid documents than it is to parse invalid ones.
  • Most browsers these days have an efficient “standards mode” rendering and a slower “quirks mode” rendering. Providing the valid doctype (which can only be done if you are in fact valid) causes the browser to switch to “standards mode” rendering.
  • Valid documents, when written well, can be accessed by just about anything, including Win CE devices and even many web enabled cell phones, without providing a seperate version of the markup. Valid XHTML makes that possible, because it’s validation strictness means you can degrade website’s content gracefully without breaking functionality.

XHTML achieves better placement in search engines

Content can often be placed higher in the XHTML document because elements can be positioned differently than in the order they are defined in the markup.


This post is closed to new comments.

About this page

This page contains a single post from Daniel Boerner's blog, of which Boot Camp + Windows Vista = no more Airport Extreme reboots is the latest post.

Are there more posts like this one?

Possibly. Within this blog, this post is categorized under webdev and it was posted on August 4, 2004. Those would be good places to start looking for related posts.

Next post (newer)

Previous post (older)