spacer

Home News Links People Catalog
spacer
activepages

Introduction to XHTML

If you want to know more about XML in general, you can take a look at my primer from a University of Washington 4 credit course: http://www.prism.washington.edu/lc/CL498A/xml.html. But, for most of you that may be way more than you want to know at this point in time (which is very reasonable as XML in general is outside the scope of our course). Otherwise, you can just focus on XHTML as one example of an XML-compliant language - the following comes from Wikipedia and is quite technical in nature. A good review to read, but not to get yourself overwhelmed by. This will be very useful to some of you who don't get overwhelmed. You aren't tested on any of this material but it is very good to know and contains the answers many questions you students have been asking me. By all means, you can ask me a question about anything in this document, but be sure you've used Google to search for better explanations for yourselves on any term you want more information on before you e-mail me. I'll be Googling myself to see what explanations are available in order to give you the best one that isn't too technical in nature.

XHTML Overview

XHTML is "a reformulation of the three HTML 4 document types as applications of XML 1.0".[1] The W3C also continues to maintain the HTML 4.01 Recommendation and the specifications for HTML5 and XHTML5 are being actively developed. In the current XHTML 1.0 Recommendation document, as published and revised to August 2002, the W3C comments that, "The XHTML family is the next step in the evolution of the Internet. By migrating to XHTML today, content developers can enter the XML world with all of its attendant benefits, while still remaining confident in their content's backward and future compatibility."[1]

XHTML Motivation

In the late 1990s, many considered that the future of HTML lay in the creation of a version adhering to the syntax rules of XML.[2] The then current version of HTML, HTML 4, was ostensibly an application of Standard Generalized Markup Language (SGML); however the specification for SGML was complex, and neither web browsers nor the HTML 4 Recommendation were fully conformant with it.[3] By shifting the underlying base from SGML to the simpler XML, HTML would become compatible with common XML tools.[4] Servers and proxies would be able to transform content, as necessary, for constrained devices such as mobile phones.[5]

Another key advantage was extensibility. By utilising namespaces, XHTML documents could include fragments from other XML-based languages such as Scalable Vector Graphics and MathML.[6] Finally, the renewed work would provide an opportunity to divide HTML into reusable components (XHTML Modularization) and clean up untidy parts of the language.[7]

XHTML Relationship to HTML

HTML is the antecedent technology to XHTML. The changes from HTML to first-generation XHTML 1.0 are minor and are mainly to achieve conformance with XML. The most important change is the requirement that the document must be well-formed and that all elements must be explicitly closed as required in XML.[8] In XML, all element and attribute names are case-sensitive, so the XHTML approach has been to define all tag names to be lowercase.

This contrasts with some earlier established traditions that began around the time of HTML 2.0, when many used uppercase tags. In XHTML, all attribute values must be enclosed by quotes; either single (') or double (") quotes may be used. In contrast, this was sometimes optional in SGML-based HTML, where attributes can omit quotes in certain cases.[9] All elements must also be explicitly closed, including empty (aka singleton) elements such as img and br. This can be done by adding a closing slash to the start tag, e. g., <img /> and <br />. Attribute minimization (e. g., <option selected>) is also prohibited, as the attribute selected contains no explicit value; instead this would be written as <option selected="selected">.

HTML elements that are optional in the content model will not appear in the DOM tree unless they are explicitly specified. For example, an XHTML page must have a <body> element, and a table will not have a <tbody> element unless the author specifies one.

The XHTML 1.0 recommendation devotes a section to differences between HTML and XHTML.[10] The WHATWG wiki similarly considers differences that arise with the use of (X)HTML5.[11]

Because XHTML and HTML are closely related technologies, sometimes they are written about and documented in parallel. In such circumstances, some authors conflate the two names by using a parenthetical notation, such as (X)HTML. This indicates that the documentation and principles can be considered to apply generally to both standards.[12]

XHTML Adoption

The similarities between HTML 4.01 and XHTML 1.0 led many web sites and content management systems to adopt the initial W3C XHTML 1.0 Recommendation. To aid authors in the transition, the W3C provided guidance on how to publish XHTML 1.0 documents in an HTML-compatible manner, and serve them to browsers that were not designed for XHTML.[13][14]

Such "HTML-compatible" content is sent using the HTML media type (text/html) rather than the official Internet media type for XHTML (application/xhtml+xml). When measuring the adoption of XHTML to that of regular HTML, therefore, it is important to distinguish whether it is media type usage or actual document contents that is being compared.

Most web browsers have mature support[15] for all of the possible XHTML media types.[16] The notable exception is Internet Explorer by Microsoft; rather than rendering application/xhtml+xml content, a dialog box invites the user to save the content to disk instead. Both Internet Explorer 7 (released in 2006) and Internet Explorer 8 Release Candidate 1 (released in January 2009) exhibit this behavior, and it is unclear whether this will be resolved in a future release.[17] As long as this remains the case, most web developers avoid using XHTML that isn't HTML-compatible,[18] so advantages of XML such as namespaces, faster parsing and smaller-footprint browsers do not benefit the user. Microsoft developer Chris Wilson explained in 2005 that IE7's priorities were improved security and CSS support, and that proper XHTML support would be difficult to graft onto IE's compatibility-oriented HTML parser.[19]

XHTML Criticism

In the early 2000s, some web developers began to question why Web authors ever made the leap into authoring in XHTML.[20][21][22] Others countered that the problems ascribed to the use of XHTML could mostly be attributed to two main sources: the production of invalid XHTML documents by some Web authors and the lack of support for XHTML built into IE6.[23][24] They went on to describe the benefits of XML-based Web documents (i.e. XHTML) regarding searching, indexing and parsing as well as future-proofing the Web itself.

In October 2006, HTML inventor and W3C chair Tim Berners-Lee, introducing a major W3C effort to develop new XHTML5 and HTML5 specifications, posted in his blog that, "The attempt to get the world to switch to XML ... all at once didn't work. The large HTML-generating public did not move ... Some large communities did shift and are enjoying the fruits of well-formed systems ... The plan is to charter a completely new HTML group."[25] In the current HTML and XHTML 5 working draft, its authors say that, "special attention has been given to defining clear conformance criteria for user agents in an effort to improve interoperability", "...while at the same time updating the HTML specifications to address issues raised in the past few years." Ian Hickson, author of the important paper criticising the use of XHTML in 2002[20], is a member of the group developing this specification and is listed as one of the co-authors of the current working draft.[26]

Versions of XHTML

XHTML 1.0

December 1998 saw the publication of a W3C Working Draft entitled Reformulating HTML in XML. This introduced Voyager, the codename for a new markup language based on HTML 4 but adhering to the stricter syntax rules of XML. By February 1999 the specification had changed name to XHTML 1.0: The Extensible HyperText Markup Language, and in January 2000 it was officially adopted as a W3C Recommendation.[27] There are three formal DTDs for XHTML 1.0, corresponding to the three different versions of HTML 4.01:

  • XHTML 1.0 Strict is the equivalent to strict HTML 4.01, and includes elements and attributes that have not been marked deprecated in the HTML 4.01 specification.
  • XHTML 1.0 Transitional is the equivalent of HTML 4.01 Transitional, and includes the presentational elements (such as center, font and strike) excluded from the strict version.
  • XHTML 1.0 Frameset is the equivalent of HTML 4.01 Frameset, and allows for the definition of frameset documents—a common Web feature in the late 1990s.

The second edition of XHTML 1.0 became a W3C Recommendation in August 2002.[28]

Modularization of XHTML

Modularization provides an abstract collection of components through that XHTML can be subsetted and extended. The feature is intended to help XHTML extend its reach onto emerging platforms, such as mobile devices and Web-enabled televisions. The initial draft of Modularization of XHTML became available in April 1999, and reached Recommendation status in April 2001.[29]

The first XHTML Family Markup Languages to be developed with this technique were XHTML 1.1 and XHTML Basic 1.0. Another example is XHTML-Print (W3C Recommendation, September 2006), a language designed for printing from mobile devices to low-cost printers.[30]

In October 2008 Modularization of XHTML was superseded by XHTML Modularization 1.1, which adds an XML Schema implementation.[31]

XHTML 1.1—Module-based XHTML

XHTML 1.1 evolved out of the work surrounding the initial Modularization of XHTML specification. The W3C released a first draft in September 1999; Recommendation status was reached in May 2001.[32] The modules combined within XHTML 1.1 effectively recreate XHTML 1.0 Strict, with the addition of ruby annotation elements (ruby, rbc, rtc, rb, rt and rp) to better support East-Asian languages. Other changes include removal of the lang attribute (in favour of xml:lang), and removal of the name attribute from the a and map elements.

Although XHTML 1.1 is largely compatible with XHTML 1.0 and HTML 4, in August 2002 the W3C issued a formal Note advising that it should not be transmitted with the HTML media type.[33] With limited browser support for the alternate application/xhtml+xml media type, XHTML 1.1 proved unable to gain widespread use. In January 2009 a second edition of the document was issued, relaxing this restriction and allowing XHTML 1.1 to be served as text/html.[34]

XHTML 1.1 Second Edition is expected in the first quarter of 2009.[35]

XHTML Basic and XHTML-MP

To support constrained devices, XHTML Basic was created by the W3C; it reached Recommendation status in December 2000.[36] XHTML Basic 1.0 is the most restrictive version of XHTML, providing a minimal set of features that even the most limited devices can be expected to support.

The Open Mobile Alliance and its predecessor the WAP Forum released three specifications between 2001 and 2006 that extended XHTML Basic 1.0. Known as XHTML Mobile Profile or XHTML-MP, they were strongly focussed on uniting the differing markup languages used on mobile handsets at the time. All provide richer form controls than XHTML Basic 1.0, along with varying levels of scripting support.

XHTML Basic 1.1 became a W3C Recommendation in July 2008, superseding XHTML-MP 1.2.[37] XHTML Basic 1.1 is almost but not quite a subset of regular XHTML 1.1. The most notable addition over XHTML 1.1 is the inputmode attribute—also found in XHTML-MP 1.2—which provides hints to help browsers improve form entry.

XHTML 1.2

The XHTML 2 Working Group is considering the creation a new language based on XHTML 1.1.[38] If XHTML 1.2 is created, it will include WAI-ARIA and role attributes to better support accessible web applications, and improved Semantic Web support through RDFa. The inputmode attribute from XHTML Basic 1.1, along with the target attribute (for specifying frame targets) may also be present. It's important to note that the XHTML2 WG have not yet been chartered to carry out the development of XHTML1.2, this means that the XHTML1.2 proposal may not eventuate.

XHTML 2.0

Between August 2002 and July 2006 the W3C released the first eight Working Drafts of XHTML 2.0, a new version of XHTML able to make a clean break from the past by discarding the requirement of backward compatibility. This lack of compatibility with XHTML 1.x and HTML 4 caused some early controversy in the web developer community.[39] Some parts of the language (such as the role and RDFa attributes) were subsequently split out of the specification and worked on as separate modules, partially to help make the transition from XHTML 1.x to XHTML 2.0 smoother. A ninth draft of XHTML 2.0 is expected to appear in 2009.

New features introduced by XHTML 2.0 include:

  • HTML forms will be replaced by XForms, an XML-based user input specification allowing forms to be displayed appropriately for different rendering devices.
  • HTML frames will be replaced by XFrames.
  • The DOM Events will be replaced by XML Events, which uses the XML Document Object Model.
  • A new list element type, the nl element type, will be included to specifically designate a list as a navigation list. This will be useful in creating nested menus, which are currently created by a wide variety of means like nested unordered lists or nested definition lists.
  • Any element will be able to act as a hyperlink, e. g., <li href="articles.html">Articles</li>, similar to XLink. However, XLink itself is not compatible with XHTML due to design differences.
  • Any element will be able to reference alternative media with the src attribute, e. g., <p src="lbridge.jpg" type="image/jpeg">London Bridge</p> is the same as <object src="lbridge.jpg" type="image/jpeg"><p>London Bridge</p></object>.
  • The alt attribute of the img element has been removed: alternative text will be given in the content of the img element, much like the object element, e. g., <img src="hms_audacious.jpg">HMS <span class="italic">Audacious</span></img>.
  • A single heading element (h) will be added. The level of these headings are determined by the depth of the nesting. This allows the use of headings to be infinite, rather than limiting use to six levels deep.
  • The remaining presentational elements i, b and tt, still allowed in XHTML 1.x (even Strict), will be absent from XHTML 2.0. The only somewhat presentational elements remaining will be sup and sub for superscript and subscript respectively, because they have significant non-presentational uses and are required by certain languages. All other tags are meant to be semantic instead (e. g. <strong> for strong or bolded text) while allowing the user agent to control the presentation of elements via CSS.
  • The addition of RDF triple with the property and about attributes to facilitate the conversion from XHTML to RDF/XML.