link (HTML element)
Example
In this example, a
link element references a style sheet for the current
document:
<link rel="stylesheet" href="basic.css"/>
- Type
- head element
- Contains
- nothing
- Contained by
head
Description
The
link element is used to create links between the
referencing document and an external resource; we define the type of this
relationship with the use of the rel and rev attributes. The
link element is most commonly used for the purpose of
linking to one or more style sheets for the document, but may also be used
to identify relationships between web pages—for example, which page is the
logical next or previous page in a sequence, which page is the contents
page for the current page, and so on. Although this use of the
link element is well intended, it has few practical
uses for the person browsing your site, as the navigation-type link
relationships don’t provide any clear method of navigating—the user still
needs to use whatever controls are visible on the page.
Arguably, it may be better to avoid using the
link element for anything other than linking
to a style sheet if you’re hand-coding your web site. If your web site’s
content is dynamically generated, it may not be difficult to automatically
identify the necessary relationships in the link
element. On the other hand, if the web site is a roll-your-own affair, it
may constitute an unnecessary overhead, and one that’s soon
neglected.
The link may only appear
in the head, but there’s no limit to
the number of individual link elements that you can
include (a quick look at the source code of any blog powered by WordPress
reveals a whole raft of auto-generated link elements
relating to archives).
Use This For …
This element’s used to link to style sheets, and to define relationships between pages—particularly in CMS-generated sites that can automate this process.
Compatibility
| IE | 5.5 | Partial |
|---|---|---|
| 6.0 | Partial | |
| 7.0 | Partial | |
| Firefox | 1.0 | Partial |
| 1.5 | Partial | |
| 2.0 | Partial | |
| Safari | 1.3 | Partial |
| 2.0 | Partial | |
| 3.0 | Partial | |
| Opera | 9.2 | Partial |
| 9.5 | Partial |
Excellent browser support is provided for referencing external style sheets, but there’s no real support for anything else.
In this Section
- charset
identifies the character set used in the referenced (or linked) document - href
specifies the location of the document or resource reference in thelinkelement - media
defines the types of media that the referenced resource (such as a style sheet) should apply to - rel
defines the relationship of the resource that’s being linked to - rev
defines the relationship the referenced resource classifies itself as having with the referencing document - target
defines the window or frame in which the referenced document resides
Related Reading
User-contributed notes
- ID:
- #2
- Date:
- Wed, 26 Mar 2008 13:38:34 GMT
there are not many practical uses for the person browsing your site, as the navigation-type link relationships don’t provide any clear method of navigating around'
Browsers like Lynx, Opera and Firefox can provide a navigation bar based on LINK elements, so that statement is not really accurate.
Add a note
To post a note on this topic, please log in with your SitePoint username and password. If you don't have an account yet, you can create a new account for free.

