Contents
This section is informative.
XHTML 2 is a general purpose markup language designed for representing documents for a wide range of purposes across the World Wide Web. To this end it does not attempt to be all things to all
people, supplying every possible markup idiom, but to supply a generally useful set of elements, with the possibility of extension using the class
attribute on the span
and
div
elements in combination with stylesheets, and attributes from the metadata attributes collection.
In designing XHTML 2, a number of design aims were kept in mind to help direct the design. These included:
Because earlier versions of HTML were special-purpose languages, it was necessary to ensure a level of backwards compatibility with new versions so that new documents would still be usable in older browsers. However, thanks to XML and stylesheets, such strict element-wise backwards compatibility is no longer necessary, since an XML-based browser, of which at the time of writing means more than 95% of browsers in use, can process new markup languages without having to be updated. Much of XHTML 2 works already in existing browsers; much, but not all: just as when forms and tables were added to HTML, and people had to wait for new version of browsers before being able to use the new facilities, some parts of XHTML 2, such as XForms and XML Events, still require user agents that understand that functionality.
The very first version of HTML was designed to represent the structure of a document, not its presentation. Even though presentation-oriented elements were later added to the language by browser manufacturers, HTML is at heart a document structuring language. XHTML 2 takes HTML back to these roots, by removing all presentation elements, and subordinating all presentation to stylesheets. This gives greater flexibility, greater accessibility, more device independence, and more powerful presentation possibilities, since stylesheets can do more than the presentational elements of HTML ever did.
The original versions of HTML relied upon built-in knowledge on the part of User Agents and other document processors. While much of this knowledge had to do with presentation (see above), the bulk of the remainder had to do with the relationships between documents — so called "linking".
A variety of W3C and other efforts, most notably [XLINK], attempted to create a grammar for defining the characteristings of linking. Unfortunately, these grammars all fall short of the requirements of XHTML. While the community continues in its efforts to create a comprehensive grammar, the HTML Working Group has defined a grammar that is sufficient for its needs. The linking constructs in this document are described in terms of this grammar, [HLINK].
Note that by describing the linking characteristics using [HLINK], this document is NOT requiring that implementations support the HLINK constructs or grammar, just as it does not require implementations support [CSS2] even though some presentation aspects of this document are defined using CSS. Instead, the document relies upon this grammar as a formalism for ensuring that the characteristics of inter-document "links" can be described in a consistent manner, and thus implemented consistently.
XHTML 2 is designed to be recognizable to the HTML and XHTML 1 author, while correcting errors and insufficiencies identified in earlier versions of the HTML family, and taking the opportunity to make improvements.
The most visible changes are the following:
hr
element was used to separate sections of a text from each other. In retrospect, the name hr
(for horizontal
rule) was badly chosen, because an hr
was neither necessarily horizontal (in vertical text it was vertical), nor necessarily a rule (books often use other typographical methods to
represent separators, such as a line of three asterisks, and stylesheets can be used to give you this freedom). In order to emphasize its structuring nature, and to make it clearer that it has no
essential directionality, hr
has been renamed separator.br
element was used to add micro-structure to text, essentially breaking a piece of text into several 'lines'. This micro-structure is
now made explicit in XHTML 2 with the l element, which encloses the text to be broken. Amongst other advantages, this gives more presentational
opportunities, such as the ability to automatically number lines, or to color alternate lines differently.Images: the HTML img
element has many shortcomings: it only allows you to specify a single resource for an image, rather than offering the fallback opportunities of the object element; the only fallback option it gives is the alt
text, which can only be plain text, and not marked up in any way; the
longdesc
attribute which allows you to provide a long description of the image is difficult to author and seldom supported.
XHTML 2 takes a completely different approach, by taking the premise that all images have a long description and treating the image and the text as equivalents. In XHTML 2 any element may
have a src attribute, which specifies a resource (such as an image) to load instead of the element. If the resource is unavailable
(because of network failure, because it is of a type that the browser can't handle, or because images have been turned off) then the element is used instead. Essentially the longdesc
has
been moved into the document, though this behavior also mimicks the fallback behavior of the object element. (To achieve the tooltip
effect that some browsers gave with the alt
attribute, as in HTML4 you use the title attribute).
ins
and del
elements to mark changes in a document, an attribute edit may be used
on any element for the same purpose.<li><a
href="home.html">Home</a></li>
, you can now write <li href="home.html">Home</li>
. Even though this means that the a element is now strictly-speaking unnecessary, it has been retained.Events: event handling in HTML was restricted in several ways: since the event names were hard-wired in the language (such as onclick
), the only way to add new events was to change
the language; many of the events (such as click
) were device-specific, rather than referring to the intent of the event (such as activating a link); you could only handle an event in one
scripting language — it was not possible to supply event handlers in the same document for several different scripting languages.
XHTML 2 uses XML Events [XMLEVENTS] to specify event handling, giving greater freedom in the ability to handle events.
XHTML 2 is a member of the XHTML Family of markup languages. It is an XHTML Host Language as defined in XHTML Modularization. As such, it is made up of a set of XHTML Modules that together describe the elements and attributes of the language, and their content model. XHTML 2 updates many of the modules defined in XHTML Modularization 1.0 [XHTMLMOD], and includes the updated versions of all those modules and their semantics. XHTML 2 also uses modules from Ruby [RUBY], XML Events [XMLEVENTS], and XForms [XFORMS].
The modules defined in this specification are largely extensions of the modules defined in XHTML Modularization 1.0. This specification also defines the semantics of the modules it includes. So, that means that unlike earlier versions of XHTML that relied upon the semantics defined in HTML 4 [HTML4], all of the semantics for XHTML 2 are defined either in this specification or in the specifications that it normatively references.
Even though the XHTML 2 modules are defined in this specification, they are available for use in other XHTML family markup languages. Over time, it is possible that the modules defined in this specification will migrate into the XHTML Modularization specification.