14. XHTML Linking Module


This section is normative.

The Link Module defines an element that can be used to define links to external resources. These resources are often used to augment the user agent's ability to process the associated XHTML document. The element and attributes included in this module are:

Elements Attributes Minimal Content Model
link Common, charset (Charset), hreflang (LanguageCode), media (MediaDesc), rel (LinkTypes), rev (LinkTypes), type (ContentType) EMPTY

When this module is used, it adds the link element to the content model of the head element as defined in the Structure Module.

Implementation: DTD

14.1. The link element


The Common collection
A collection of other attribute collections, including: Core, Events, I18N, and Hypertext
charset = Charset
This attribute specifies the character encoding of the resource designated by the link. Please consult the section on character encodings for more details.
href = URI
This attribute specifies a hypertext link that is activated when the element is selected.
hreflang = LanguageCode
This attribute specifies the base language of the resource designated by href and may only be used when href is specified.
media = MediaDesc
The value of this attribute specifies the type of media for which the element is intended.
rel = LinkTypes
This attribute describes the relationship from the current document to the URI referred to by the element. The value of this attribute is a space-separated list of link types.
rev = LinkTypes
This attribute is used to describe a reverse link from the anchor specified by the href attribute to the current document. The value of this attribute is a space-separated list of link types.
type = ContentType
This attribute gives an advisory hint as to the content type of the content available at the link target address. It allows user agents to opt to use a fallback mechanism rather than fetch the content if they are advised that they will get content in a content type they do not support.

Authors who use this attribute take responsibility to manage the risk that it may become inconsistent with the content available at the link target address.

For the current list of registered content types, please consult [MIMETYPES].

This element defines a link. Unlike a, it may only appear in the head section of a document, although it may appear any number of times. Although link has no content, it conveys relationship information that may be rendered by user agents in a variety of ways (e.g., a tool-bar with a drop-down menu of links).

This example illustrates how several link definitions may appear in the head section of a document. The current document is "Chapter2.html". The rel attribute specifies the relationship of the linked document with the current document. The values "Index", "Next", and "Prev" are explained in the section on link types.

  <title>Chapter 2</title>
  <link rel="Index" href="../index.html"/>
  <link rel="Next"  href="Chapter3.html"/>
  <link rel="Prev"  href="Chapter1.html"/>

14.1.1. Forward and reverse links

While the rel attribute specifies a relationship from this document to another resource, the rev attribute specifies the reverse relationship.

Consider two documents A and B.

Document A:       <link href="docB" rel="foo"/>

Has exactly the same meaning as:

Document B:       <link href="docA" rev="foo"/>

Both the rel and rev attributes may be specified simultaneously.

14.1.2. Links and external style sheets

When the link element links an external style sheet to a document, the type attribute specifies the style sheet language and the media attribute specifies the intended rendering medium or media. User agents may save time by retrieving from the network only those style sheets that apply to the current device.

Media descriptors are further discussed under Attribute Types.

14.1.3. Links and search engines

Authors may use the link element to provide a variety of information to search engines, including:

The examples below illustrate how language information, media types, and link types may be combined to improve document handling by search engines.

The following example shows how to use the hreflang attribute to indicate to a search engine where to find Dutch, Portuguese, and Arabic versions of a document. Note the use of the charset attribute for the Arabic manual. Note also the use of the xml:lang attribute to indicate that the value of the title attribute for the link element designating the French manual is in French.

<title>The manual in English</title>
<link title="The manual in Dutch"
<link title="The manual in Portuguese"
<link title="The manual in Arabic"
<link lang="fr" title="La documentation en Fran&ccedil;ais"

In the following example, we tell search engines where to find the printed version of a manual.

<title>Reference manual</title>
<link media="print" 
      title="The manual in postscript"

In the following example, we tell search engines where to find the front page of a collection of documents.

<title>Reference manual -- Page 5</title>
<link rel="Start" title="The first page of the manual"