What is XHTML?
XHTML is a stricter, cleaner version of HTML.
XML is a hot topic among web developers. Its promise of a standardized markup that separates display and layout code from syntax really hits home if you've ever experienced the frustration of parsing loose code.
But that's just one example of how a strict, standardized markup standard can make programming easier. As we watch the growing trend of portable web-enabled devices, we realize they will require a compact code using standardized markup. Getting to that point, however, isn't going to be easy.
Whether your site has 10 pages or 10,000, it's likely that the HTML code is a mix of standard HTML and browser-specific, proprietary markup. If you've been thinking about making the transition to XML, or even just standardizing your HTML code, here's the solution: XHTML (Extensible Hypertext Markup Language).
XML + HTML = XHTML (sort of)
Let's take a quick look at how these markup languages fit together.
- HTML is a markup language described in SGML (Standard Generalized Markup Language).
- XML is a restricted form of SGML, removing many of SGML's more complex features, but preserving most of SGML's power and commonly used features.
- XHTML is the reformulation of HTML 4.0 as an application of XML.
The W3C (World Wide Web Consortium) has taken the logical step of expressing the HTML 4.0 standard in XML instead of using the more complicated SGML.
The minute details aren't too important for the average web coder, but the main difference is found in the document type definitions (DTDs) used by HTML and XHTML. A DTD, according to the W3C, is "a collection of declarations that, as a collection, defines the legal structure, elements, and attributes that are available for use in a document that complies to the DTD."
In other words, it's a definition of what is legal syntax in HTML (or XHTML) and what isn't. The DTD for XHTML is more restrictive than the DTD for HTML because XML is more restrictive than SGML.
The W3C gives two main reasons for recommending XHTML as the next step from HTML 4.0. First, XHTML, since it's an XML application, is designed to be extensiblethat's the "X" in all the acronyms. This means that new tags or "elements" in the official W3C jargon can be added without altering the entire DTD that the document is based on.
Second, XHTML is designed for portability. web browsers have become behemoths of code bloat. You name it, there's code in the newest browsers to do it. But according to some estimates cited by the W3C, by 2002, 75 percent of web document viewing will be through non-desktop devices like palm computers, televisions, toasters, and other alternative platforms, not through browsers on PCs. Your web-enabled toaster will have less room for bloated code, and its browser will need to be able to count on standards-based documents. It may not be able to display current incarnations of HTML because of the non-standard code involved.
To help you see the main differences between HTML and XHTML, we've included a number of examples in the following section, "Differences." You'll see that most of the variances are simply stricter definitions of common HTML tags.
There are, however, some new features, which we cover in the third section, "What's New."
XHTML Part 2: Differences
What are the differences when coding in XHTML? For many developers the changes are minor, that is, unless you love uppercase tags.
XHTML Part 3: What's New
XHTML does require a doctype declaration and won't allow open <br> tags. But the changes are less different than you think.