HTML <link> tag

The <link> tag is used to specify a relationship between an HTML document and an external resource. The <link> tag should be placed in the head section of an HTML document.

NOTE: The <link> tag has no end tag.

Attributes

Attribute Description Possible values
charset Specifies the external resource's character encoding charEncoding
href Specifies the location of the external resource theLocation
hreflang Specifies the language of the data at the external resource theLanguage
media Specifies the device on which the external resource will be displayed screen, tty, tv, projection, handheld, print, braille, aural, all
rel Specifies the relationship between the HTML document and the external resource alternate, appendix, bookmark, chapter, contents, copyright, glossary, help, home, index, next, prev, section, start, stylesheet, subsection
rev Specifies a reverse relationship between the external resource and the HTML document alternate, appendix, bookmark, chapter, contents, copyright, glossary, help, home, index, next, prev, section, start, stylesheet, subsection
target Specifies where to open the external resource _blank, _self, _parent, _top
type Specifies the MIME type of the external resource MIMEtype

Standard attributes

class, dir, id, lang, style, title, xml:lang

For more information on standard attributes, check out our HTML standard attributes reference page.

Event attributes

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

For more information on event attributes, check out our HTML event attributes reference page.

Example

<html> <head> <title>Using the <link> tag</title> <link rel="stylesheet" type="text/css" href="/styles/style.css" /> </head> <body> <p> The linked stylesheet will make this webpage's background blue and the text white in a Tahoma font. </p> </body> </html>

Output:

The linked stylesheet will make this webpage's background blue and the text white in a Tahoma font.

Tips & notes

Use the <link> tag to link external stylesheets to your pages. This will make your pages and the elements on them have the styles set in the external stylesheets.

Web Reference
  1. CSS reference
  2. RSS reference
  3. HTML reference


© Copyright 2011-2012 Landofcode.com
Terms of use | Privacy policy | Copyright information | Make a donation