by Thomas Erl
The HTML specification, currently in its 4th revision, has been the preeminent markup language used for Web publishing over the past decade. Providing a fixed (non-extensible) set of markup tags, however, has been one of HTML’s primary limitations. Additionally, HTML coding rules are extremely flexible, allowing for the inconsistent authoring and design of Web pages. These two characteristics put HTML in sharp contrast to XML, which provides an extensible framework and enforces strict coding standards based on concepts of well-formedness and validity.
As owners of both the HTML and XML specifications, the World Wide Web Consortium (W3C) has decided not to continue developing HTML. Instead, the functionality of HTML will be provided through an implementation of XML in a new markup language called XHTML.
Besides providing a consistent and extensible platform for presentation-level code, one of the W3C’s primary objectives is to deliver user-interface portability, allowing Web pages to become device-independent. To accomplish this, a stripped down version of XHTML, called XHTML Basic, has been created and defined in a separate specification that achieved recommendation status last December.
To Web designers and authors, XHTML 1.0 will likely be looked upon as just another version of HTML, but to back-end developers, it provides a new framework for the manipulation of Web user-interfaces in alignment with XML.
XHTML 1.0 supports all of the tags defined in HTML 4.0, but the original DTDs used by HTML have been replaced with the following three XML DTDs:
<!DOCTYPE html PUBLIC “-//W3C XHTML 1.0 Strict//EN”
<!DOCTYPE html PUBLIC “-//W3C XHTML 1.0 Transitional//EN”
<!DOCTYPE html PUBLIC “-//W3C XHTML 1.0 Frameset//EN”
XHTML places a great deal of emphasis on the use of Cascading Style Sheets (CSS), and therefore supplies the Strict DTD which requires that all style attributes be placed in a separate CSS. The Transitional DTD permits the use of embedded style attributes for Web pages that need to support browsers which do not support CSS. The Frameset DTD is for the use of standard HTML frameset files.
Each of these DTDs impose a stricter adherence to well-formed coding rules. So strict, in fact, that use of any of these DTDs would invalidate 99% of the HTML content currently on the Web.
Web authors must place a reference to one of these DTDs at the beginning of every XHMTL document. Additionally, the HTML tag itself can contain a namespace reference allowing it to point to the standard W3C XHTML specification, or a customized extension.
The most significant changes Web authors will encounter when working with XHTML are syntactical. For instance, as with XML code, all XHTML body code must be lowercase, as follows:
Incorrect: < P ALIGN=”CENTER”>Life can be hell with XHTML</P>
Correct: < p align=”center”>Life can be swell with XHTML</p>
Additionally, element attributes must be enclosed with quotation marks, as follows:
Incorrect: <p align=center>Life can be hell with XHTML</p>
Correct: <p align=”center”>Life can be swell with XHTML</p>
In order to comply with the well-formedness rules, all XHTML tag constructs must be properly nested, as follows:
Incorrect: <p align=”center”><b>Life’s a beech with XHTML</p></b>
Correct: <p align=”center”><b>Life’s a peach with XHTML</b></p>
…and end-tags must always be supplied:
Incorrect: <p align=”center”><b>Life’s a beech with XHTML</p>
Correct: <p align=”center”><b>Life’s a peach with XHTML</b></p>
Finally, one of the major changes to traditional HTML coding requires that all standalone tags (elements that do not require end-tags) be modified with a termination character, as follows:
Incorrect: <img src=”sadface.jpg”><br>
Correct: <img src=”happyface.jpg” /><br />
A complete XHTML-compliant document would appear as follows:
<!DOCTYPE html PUBLIC “-//W3C XHTML 1.0
Transitional//EN” “DTD/xhtml1- transitional.dtd”>
Life can be swell,<br />
<img src=”happyface.jpg” />
The above samples illustrate only some of the coding rules enforced by XHTML. The slightest violation of these rules will result in a validation error, preventing the Web page from being displayed. In addition to the obvious benefits of having all Web page syntax consistently coded and structured, this framework requires XHTML parsing engines to do less work than traditional HTML parsers (which were designed to compensate for inconsistent HTML coding), and as a result reduces the footprint and processing requirements for Web pages and user interfaces. This opens up the use of XHTML (through the XHTML Basic subset) to mobile and other non-browser devices with more restrictive system requirements (hence achieving the W3C’s objective of providing portability).
Also worth mentioning is the emergence of the XHTML 1.1 specification, which trims the presentation tag feature set even more by dropping support for previously deprecated elements and attributes, again placing more emphasis on the use of CSS. Finally, an XML Events specification is being developed (currently a W3C working draft), which promises to integrate XHTML behaviours with DOM event interfaces. (A “basic” version of the XML Events specification is also being drafted.)
Even though the XHTML 1.0 specification achieved W3C recommendation status over a year ago, industry adoption of XHTML may be slow, due to the amount of coding changes required for existing HTML content to conform. It is anticipated that the introduction of mass HTML-to-XHTML conversion tools will become available to accelerate the acceptance rate of XHTML into the mainstream. Either way, it is likely inevitable that XHTML will eventually become the Web’s next global standard presentation language.
- Inside XML Schemas
- SOAP in a Nutshell
- Transforming Data with XSLT
- Understanding DTDs
- Why SAX is Good for DOM
- What You Should Know about XPath
- An XHTML Primer
- XLink - Inside and Out
- Data Access with XQuery
- XSL versus CSS
- Another Introduction to XML
- Unifying Corporate Data & Documents
- Replacing HTML Documents with XML
- Meta-Enable Your Enterprise
- The XML Data Custodian
- Integrating XML into the Enterprise
- The Wireless Enterprise
Foreword by Grady Booch
With contributions from David Chappell, Jason Hogg, Anish Karmarkar, Mark Little, David Orchard, Satadru Roy, Thomas Rischbeck, Arnaud Simon, Clemens Utschig, Dennis Wisnosky, and others.
Governing Shared Services On-Premise & in the Cloud by Stephen Bennett, Thomas Erl, Clive Gee, Anne Thomas Manes, Robert Schneider, Leo Shuster, Andre Tost, Chris Venable
For more information about these books, visit: www.servicetechbooks.com