link Element


 

Module

The link element is declared by the XHTML 1.1 Link Module

This is the only element in this Module.

Description

The link element allows the author to specify URIs which are related to the current document: parent documents, glossaries, search pages, etc. Either the rel or rev attribute can be used, depending on the direction of the relationship. For more information see the LinkTypes Attribute Type.

link elements may be placed only within the head element and are not rendered as part of the document content, although user agents may allow certain LinkTypes to be accessed by the user through other means - for example, in *Opera, by using the "Navigation Bar". Search engines may possibly make use of certain LinkTypes to determine the structure of a site and some browsers may prefetch rel="next" pages to speed up browsing - see, for example *Mozilla - Link prefetching FAQ, where rel="prefetch" can also be used. Users who wish to disable link prefetching in Firefox (e.g. for privacy, security or bandwidth reasons) can go to about:config and set network.prefetch-next to false.

For example:

<head>
  <title>Page 2: Getting Started</title>
  <link rel="prev" href="/en/p1.html" title="Page 1: Introduction" />
  <link rel="next" href="/en/p3.html" title="Page 3: Advanced Use" />
  <link rel="glossary" href="/en/glossary.html" />
  <link rel="alternate" hreflang="de" href="/de/p2.html" title="German Version of this Page" />
  <link rel="search" href="/search" />
</head>

Stylesheets

If rel is given the value "stylesheet" (or "alternate stylesheet") the linked URI should specify a stylesheet which may be used when rendering the document. The type attribute should then be added, stating the MIME type of the stylesheet language (usually "text/css"). Optionally, the media attribute may be used to indicate the media type(s) for which the stylesheet applies (see the MediaDesc attribute type) and/or a title attribute can be added to designate the stylesheet as either the preferred author style (with rel="stylesheet") or as an alternative style (with rel="alternate stylesheet"). Without a title attribute, linked stylesheets are persistent - i.e. they are always loaded. See the W3C Recommendation *HTML 4.01 - External style sheets for more information.

Note that relative paths in external CSS stylesheets (e.g. when specifying background images) are with respect to the stylesheet's URI and not the document's base URI.

For example:

<link rel="stylesheet" type="text/css" href="/style/style.css" media="print" />
<link rel="stylesheet" type="text/css" href="/style/normal.css" title="Normal (Preferred Style)" />
<link rel="alternate stylesheet" type="text/css" href="/style/high.css" title="High Contrast (Alternate Style)" />

In XHTML which is not served as "text/html", you can alternatively use *xml-stylesheet processing instructions to specify your styles. XML processing instructions should come after any XML declaration but before the DOCTYPE (see XML Declaration & DOCTYPE).

For example:

<?xml-stylesheet type="text/css" href="/style/style.css"?>
<?xml-stylesheet type="text/css" href="/style/normal.css" title="Normal (Preferred Style)"?>
<?xml-stylesheet alternate="yes" type="text/css" href="/style/high.css" title="High Contrast (Alternate Style)"?>

#REQUIRED Attributes

There are no #REQUIRED attributes on the link element.


Specific Attributes

Specific attributes of the link element are listed below:

From the Link Module - the Element's own Module

charset [ type Charset ]
The character encoding of the linked resource, e.g. "ISO-8859-1"
href [ type URI ]
The URI of the linked resource
hreflang [ type LanguageCode ]
The language code (e.g. "en") of the resource at the URI specified by the href attribute
media [ type MediaDesc ]
The medium or media for which the linked resource applies, e.g. "screen"
rel [ type LinkTypes ]
Specifies the (forward) relationship from the current document to the resource specified by the href attribute - e.g. a value of "stylesheet" specifies that the resource is a stylesheet for the current document (if desired, a space separated list of relationships may be given)
rev [ type LinkTypes ]
Specifies the reverse relationship between the current document and the resource specified by the href attribute - i.e. the relationship from that other resource to the current document - e.g. a value of "glossary" specifies that the current document is a glossary for the resource (if desired, a space separated list of relationships may be given)
type [ type ContentType ]
The content type of the linked resource, e.g. "text/css"

From the Target Module

target [ type FrameTarget ]
Indicates the window or frame in which to open the link

Common Attributes

Common attributes of the link element are listed below:

From the Core Attribute Collection

class [ type NMTOKENS ]
One or more space separated classes
id [ type ID ]
A unique identifier for the element
style [ type CDATA ], from the Style Attribute Module (deprecated)
Element-specific styles
title [ type Text ]
A title for the element - for stylesheets this attribute is used to specify the title of the preferred or alternate stylesheet to which the linked sheet belongs
xmlns [ type URI - #FIXED 'http://www.w3.org/1999/xhtml' ]
XML namespace

From the I18N Attribute Collection

dir [ type Enumeration (ltr | rtl) ], from the Bi-directional Text Module
Left-to-right or right-to-left directionality
xml:lang [ type LanguageCode ]
A language code for the element

From the Events Attribute Collection

All attributes in the Events Attribute Collection are supported:
onclick, ondblclick, onmousedown, onmouseup, onmouseover, onmousemove, onmouseout, onkeypress, onkeydown, onkeyup


Content Model

The Content Model for the link element is:

EMPTY

See Content Model & Nesting for information about Content Model syntax and Nesting Groups.

Valid children of link

This element is empty and may have no children.

Valid parents of link


Page Footer & Copyright

Copyright © Sally Maughan 2005-2009 (Page last updated on 01 Oct 2009)

*Valid XHTML 1.1 - hosted by *Openstrike

Content based on the W3C Working Draft: *XHTML 1.1 and Recommendation: *XHTML Modularisation 1.1.

W3C, XHTML, XML, HTML, CSS and MathML are *Trademarks of the W3C (*MIT, *ERCIM, *Keio) with which the site's author has no connection.


Up, Next & Previous Links

Your Location

Home > XHTML 1.1 Home > XHTML 1.1 Indexes > Element Index (XHTML 1.1) > link Element