HTML XHTML The Complete Reference
home » reference » appendix a » html element reference

<link> (Link to External Files or Set Relationships)


This empty element specifies relationships between the current document and other documents. Possible uses for this element include defining a relational framework for navigation and linking the document to a style sheet.

Standard Syntax


<link
charset="charset list from RFC 2045"
class="class name(s)"
dir="ltr | rtl"
href="URL"
hreflang="language code"
id="unique alphanumeric identifier"
lang="language code"
media="all | aural | braille | print | projection |
screen | other"
rel="relationship value"
rev="relationship value"
style="style information"
target="frame name" (transitional only)
title="advisory information"
/>

Common Attributes


disabled="disabled " (from DOM Level 1)

Standard Event Attributes


onclick, ondblclick, onkeydown, onkeypress, onkeyup, onmousedown, onmousemove, onmouseout, onmouseover, onmouseup

Events Defined by Internet Explorer


onload, onreadystatechange

Element Specific Attributes


charset
This attribute specifies the character set used by the linked document. Allowed values for this attribute are character set names, such as EUC-JP, as defined in RFC 2045.

disabled
This Microsoft-defined attribute is used to disable a link relationship. The presence of the attribute is all that is required to remove a linking relationship. In conjunction with scripting, this attribute could be used to turn on and off various style sheet relationships.

href
This attribute specifies the URL of the linked resource. A URL might be absolute or relative.

hreflang
This attribute is used to indicate the language of the linked resource. See "Language Reference," earlier in this appendix for information on allowed values.

media
This attribute specifies the destination medium for any linked style information, as indicated when the rel attribute is set to stylesheet. The value of the attribute might be a single media descriptor such as screen or a comma-separated list. Possible values for this attribute include all, aural, braille, print, projection, and screen. Other values also might be defined, depending on the browser. Internet Explorer supports all, print, and screen as values for this attribute.

rel
This attribute names a relationship between the linked document and the current document. Possible values for this attribute include alternate, bookmark, chapter, contents, copyright, glossary, help, index, next, prev, section, start, stylesheet, and subsection.

The most common use of this attribute is to specify a link to an external style sheet. The rel attribute is set to stylesheet, and the href attribute is set to the URL of an external style sheet to format the page. WebTV also supports the use of the value next for rel to preload the next page in a document series.

rev
The value of rev attribute shows the relationship of the current document to the linked document, as defined by the href attribute. The attribute thus defines the reverse relationship compared to the value of the rel attribute. Values for the rev attribute are similar to the possible values for rel. They might include alternate, bookmark, chapter, contents, copyright, glossary, help, index, next, prev, section, start, stylesheet, and subsection.

target
The value of the target attribute is used to define the frame or window name that has the defined linking relationship or that will show the rendering of any linked resource.

type
This attribute is used to define the type of the content linked to. The value of the attribute should be a MIME type such as text/html, text/css, and so on. The common use of this attribute is to define the type of style sheet linked and the most common current value is text/css, which indicates a Cascading Style Sheet format.

Examples


<link href="products.htm" rel="parent">

<link href="corpstyle.css" rel="stylesheet" type="text/css" media="all">

<link href="nextpagetoload.htm" rel="next">

XHTML Examples


<link href="products.htm" rel="parent" />

Compatibility


HTML 2, 3.2, 4, 4.01, XHTML 1.0, 1.1, Basic
Netscape 4 – 4.7, 6
Internet Explorer 3, 4, 5, and 5.5

Notes


Under XHTML 1.0, empty elements such as <link> require a trailing slash: <link />.

A <link> tag can occur only in the head element; however, there can be multiple occurrences of <link>.

HTML 3.2 defines only the href, rel, rev, and title attributes for the link element.

HTML 2 defines the href, methods, rel, rev, title, and urn attributes for the link element. The methods and urn attributes were later removed from the specifications.

The HTML and XHTML specifications define event handlers for the link element, but it is unclear how they would be used.

(X)HTML Elements
CSS Properties
Previous: li Next: listing
< Home | About | Chapters | Examples | Errata | Reference | Site Map >