Section 11.5. Linking Documents with link


11.5. Linking Documents with link

The link element defines a relationship between the current document and another external document. It is not the same as a hypertext link because it is not accessible by clicking or otherwise selecting a hyperlink. It is always placed in the header (head) of the document. There can be multiple link elements in a document.

link

 <link /> 

Attributes

Core(id, class, style, title), Internationalization, Events
charset="charset"
href="URL"
HReflang="language code"
media="all|screen|print|handheld|projection|tty|tv|projection|braille|aural"
rel="relationships"
rev="relationships"
target="name"
type="resource"

The most important attributes are href, which points to the linked file, and rel, which describes the relationship(s) from the source document to the target document. The rev attribute describes the reverse relationship(s) (from the target back to the source).

A variety of attributes make the link element very versatile, but it is not currently used to its full potential. By far, the most popular application of the link element 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, which is required in XHTML:

 <head> <link href="wholesite.css" rel="stylesheet" type="text/css" /> </head> 

Note the use of the "/" at the end of the link element to explicitly mark it as an empty element for XHTML, while leaving a space before the "/" for compatibility with Version 4 browsers.

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:

 <head> <link rel="alternate" href="translations/french.html"       type="text/html" hreflang="fr" /> </head> 

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 next example. This information could be used by browsers and other tools to build navigation menus, tables of contents, or other link collections.

 <head> <title>Chapter 11: Creating Links</title> <link rel="prev" href="chapter10.html" /> <link rel="next" href="chapter12.html" /> </head> 

Table 11-2 lists the accepted values for the rel and rev attributes and their uses. These attributes and values can be used in the a element as well as link to define relationships for a specific link. Again, these features are not widely used, nor are they well supported by browser user interfaces.

Table 11-2. Link types using the rel attribute

Value

Relationship

alternate

Substitute version of the current document, perhaps in another language or optimized for another display medium. This value is used frequently in style sheet switching.

stylesheet

External Cascading Style Sheet; used with type="text/css".

start

The first document in a collection or series.

next

The next document in a series.

prev

The previous document in a series.

contents (or toc)

A document providing a table of contents.

index

A document providing an index for the current document.

glossary

A document containing a glossary of terms.

copyright

A document containing copyright information for the current document.

chapter

A document serving as a chapter in a collection of documents.

section

A document serving as a section in a collection of documents.

subsection

A document serving as a subsection in a collection of documents.

appendix

A document serving as an appendix.

help

A help document.

bookmark

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





Web Design in a Nutshell
Web Design in a Nutshell: A Desktop Quick Reference (In a Nutshell (OReilly))
ISBN: 0596009879
EAN: 2147483647
Year: 2006
Pages: 325

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net