Helping ordinary people create extraordinary websites!
HOME TUTORIALS SCRIPTS WEB HOSTING BLOG FORUM
Get Our Newsletter
Email:

Linking in XHTML 2.0

By Micah Dubinko
2005-05-04


The Hypertext Attribute Collection

Besides href, XHTML 2.0 supplies a collection of additional attributes to further augment the description of a link. These attributes, which are likely to change slightly by the time XHTML 2.0 reaches Last Call, are available in all the same places that href can be used:

• hreflang indicates the expected language at the remote end of the link. It may be a space-separated list.
• hreftype indicates the media type of the link destination; whether it is, say, SVG or XHTML or some other type. It too may be a space-separated list.
• cite designates a source document reference for some text, typically some kind of a quotation. Previously, this attribute existed only on elements like blockquote. Now that it is widely available, authors are thinking about richer ways to interconnect their hypertext. The interesting part is that the XHTML specification says that user agents "should" make this link available somehow. The details are left to each piece of software, but I'd expect to see this kind of link show up on a right-click menu in more-innovative browsers.
• access (which is quite different from accesskey in previous versions) assigns short names, like "contents", to various parts of a document. Accessibility tools can then handle those parts appropriately.
• The nextfocus and prevfocus attributes contain IDREFs of other elements. Taken as a whole, these form chains that guide navigation through the document, and they work for more than just anchors and form controls. The default navigation order is the same as the order in which the elements appear in the document; these attributes allow fine-tuning of navigation order. Additionally, if the XHTML document reference includes a fragment -- say http://search.example.com#query -- and the document includes a focusable element with an id of query, that element receives initial focus and serves as the starting point for further navigation.
• target and xml:base are largely unchanged in XHTML 2.0. Web authors might be accustomed to specifying target="_new" to specify that a link opens in a new window. XHTML 2.0 no longer hard-codes any special values, and instead defers to a related specification called XFrames (see Resources) to define how linked-to resources fit into the overall environment. The xml:base attribute sets up a context in which relative URLs are interpreted.

One good use for the Hypertext attribute collection is with navigation lists, a new feature in XHTML 2.0. Listing 2 illustrates:

Listing 2. Navigation list

<nl xml:base="http://xformsinstitute.com/essentials/browse/">

<label>Table of Contents</label>
<li href="ch01.php">Introduction to Web Forms</li>
<li href="ch02.php">XForms Building Blocks</li>
<li href="ch03.php">XPath in XForms</li>
...
</nl>
Navigation lists help authors direct users through their Web sites, something that many developers have tried to accomplish through forms. However, the explicit hyperlink markup is a more natural -- and more accessible -- fit for conveying navigation information.

HLink: An alternate solution?
In response to apparent shortcomings of XLink, the HTML Working Group drafted a proposal called HLink (see Resources), which leveraged the good work in XLink in a way that could be mapped to arbitrary attributes on any element. HLink had some interesting additions, like a new actuate value of onRequestSecondary for right-mouse clicks or the equivalent, and ways to handle things like form submission and error handling that weren't clear with XLink by itself.

In the end, though, HLink wasn't an appropriate solution. The terminology and semantics from XLink could be used directly, without the need for a separate layer in between.

Tutorial Pages:
» How XHTML 2.0 is Changing the Way People Think About Web Linking
» Linking: From Any Element
» The Hypertext Attribute Collection
» The Embedding Attribute Collection
» Are We There Yet?
» Resources


First published by IBM DeveloperWorks


 | Bookmark
Related Tutorials:
» Starting with XML
» Performing Client-Side XSL Transformations
» Create a Google Sitemap for your Web Site
» XML and Scripting Languages
» Parsing Comma-Separated Values
» XML Security Suite: Increasing the Security of E-Business