Link to file or relationship
This element is used in the header section of an HTML document. It can be used for including an external stylesheet for the document, or for setting a relationship between the current document and another page on the website.
<link
charset="charset code"
class="class name(s)"
dir="ltr | rtl"
href="url"
hreflang="language code"
id="unique identifier"
lang="language code"
media="all | aural | braille | print | projection |
screen | other"
rel="relationship value"
rev="relationship value"
style="style information"
target="frame name"**
title="text"
type="content type"
>
Key:
‡ = Required attribute
** = Transitional only
Explanation of attributes
charset: used to define the character encoding of the target resource. The value of this attribute is a code specified in RFC 2045, for example UTF-8 or ISO-8859-1. The default value of this attribute is ISO-8859-1.
class: used to state which class(es) the element belongs to. It is possible to indicate more than one class for an element by separating each class name with a space character. This attribute is normally used in combination with a stylesheet in order to associate the elements with particular styles defined within the stylesheet.
dir: used to set the direction of the text in combination with the language set in the lang attribute. The available values are "ltr" (left to right) and "rtl" (right to left), with the default value being "ltr".
href: used to define the URL of the document that is related to the referencing page.
hreflang: this attribute is used to specify the language in which the linked resource is written. This is specified using a language code.
id: used to specify a unique alphanumeric identifier to the element. This is usually used in combination with stylesheets in order to apply a style to one particular instance of an element. Only one element, regardless of type, can be given a particular id.
lang: used to indicate the language being used in the text contained within the element. The value of this attribute takes on the form of the ISO standard lanuage abbreviations found in RFC 3066. A list of these codes can be found on the ISO language codes page.
media: this attribute is used to define what media a linked stylesheet should be used for. It is used when the rel attribute has the value "stylesheet".
rel: used to specify the relationship between the link object and the target resource. This attribute should only be used in combination with the href attribute.
rev: this is the inverse relationship of the rel attribute. It can be used, for example, to indicate where the linked resource originated by giving the name of the author or similar.
style: used to specify an inline style to apply to the element. The styles defined here override the styles declared in the header section.
target**: used to specify the target window for the linked resource. Some of the values for this attribute are special in that they refer to specific frames, such as _blank (a new window), _parent (the parent frame), _self (the frame containing the link), and _top (the full browser window). Other values are used to target frames by the name defined in the frame element.
title: used to define an advisory text that may be displayed as a tooltip when a mouse is used to hover over the element.
type: used to define what MIME type the linked resource is, ie. what type of file it is.
Event handlers
The following event handlers are defined for this element:
- onclick
- ondbclick
- onkeydown
- onkeypress
- onkeyup
- onmousedown
- onmousemove
- onmouseout
- onmouseover
- onmouseup
Compatibility
| Test | ![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
|---|---|---|---|---|---|---|
| Basic element support | |
|
|
|
|
|
| Attribute: charset | |
|
|
|
|
|
| Attribute: class | |
|
|
|
|
? |
| Attribute: dir | |
|
|
|
|
|
| Attribute: href | |
|
|
|
|
|
| Attribute: hreflang | |
|
|
|
|
|
| Attribute: id | |
|
|
|
|
? |
| Attribute: lang | |
|
|
|
|
|
| Attribute: media | |
|
|
|
? | |
| Attribute: rel | |
|
|
|
|
|
| Attribute: rev | |
|
|
|
|
? |
| Attribute: style | |
|
|
|
|
? |
| Attribute: target | |
|
|
|
|
? |
| Attribute: title | |
|
|
|
|
? |
| Attribute: type | |
|
|
|
|
? |
Key:
The browser icons are explained in the below list:
= Microsoft Internet Explorer 6+
= Netscape Communicator 4
= Mozilla and Netscape Navigator 6+
= Opera 7+
= MSN TV (aka. WebTV)
= Konqueror 3.0+