home | O'Reilly's CD bookshelfs | FreeBSD | Linux | Cisco | Cisco Exam  

Book HomeWeb Design in a NutshellSearch this book

11.8. Linking Documents with <link>

The <link> tag is used to define a relationship between the current document and another external document. It is always placed in the header (<head>) of the document. There can be multiple <link> tags in a document. The most important attributes are href, which points to the linked file, and rel, which describes the relationship from the source document to the target document. The rev attribute describes the reverse relationship (from the target back to the source).

A variety of attributes make the <link> tag very versatile, but it is not currently used to its full potential. The most popular application of the <link> tag is for referring to an external style sheet. In this example, the type attribute identifies the MIME content type of the linked document as a cascading style sheet:

<LINK HREF="wholesite.css" REL="stylesheet" TYPE="text/css">

Another use as recommended in the HTML 4.01 specification is to refer to an alternate version of the document in another language. The following example creates a link to a French version of the document:

<LINK REL="alternate" HREF="translations/french.html" 
      TYPE="text/html" HREFLANG="fr">

By using the next and prev values for the rel attribute, you can establish the document's position in a sequence of documents, as shown in the following example. This information could be used by browsers and other tools to build navigation menus, tables of contents, or other link collections.

<TITLE>Chapter 11: Creating Links</TITLE>
<LINK REL="prev" HREF="chapter10.html">
<LINK REL="next" HREF="chapter12.html">

Table 11-1 lists the accepted values for the rel and rev attributes and their uses. These attributes and values can be used in the <a> tag as well as the <link> tag to define relationships for a specific link. Again, these features are not widely used, nor are they well supported by browsers, but they may grow in popularity.

Table 11-1. Link types using the REL attribute




Substitute version of the current document, perhaps in another language or optimized for another display medium


External cascading style sheet; used with type="text/css"


The first document in a collection or series


The next document in a series


The previous document in a series

contents (or toc)

A document providing a table of contents


A document providing an index for the current document


A document containing a glossary of terms


A document containing copyright information for the current document


A document serving as a chapter in a collection of documents


A document serving as a section in a collection of documents


A document serving as a subsection in a collection of documents


A document serving as an appendix


A help document


A document that serves as a bookmark; the title attribute can be used to name the bookmark

Library Navigation Links

Copyright © 2002 O'Reilly & Associates. All rights reserved.