HTML <link>Tag


Examples

Link to an external style sheet:

<head> <link rel="stylesheet" type="text/css" href="theme.css"> </head>

Try it Yourself »

Browser Support

Internet Explorer Firefox Opera Google Chrome Safari

All major browsers support the <link> tag.


Tag Definition and Usage Instructions

The <link> tag defines the relationship between a document and an external resource.

The most common use of the <link> tag is to link to style sheets.


Note:The link element is an empty element; it contains attributes only.

Note:This element can only exist in the head section, but it can appear any number of times.


Differences between HTML 4.01 and HTML5

Some HTML 4.01 attributes are not supported in HTML5.

HTML5 adds the "sizes" attribute.


Differences between HTML and XHTML

In HTML, the <link> tag has no end tag.

In XHTML, the <link> tag must be properly closed.


Attributes

New: HTML5 new attribute.

Attributes Value Description
charset char_encoding HTML5 does not support this attribute.Defines the character encoding of the linked document.
href URL Defines the location of the linked document.
hreflang language_code Defines the language of the text in the linked document.
media media_query Specifies on what device the linked document will be displayed.
rel alternate
archives
author
bookmark
external
first
help
icon
last
license
next
nofollow
noreferrer
pingback
prefetch
prev
search
sidebar
stylesheet
tag
up
Required. Defines the relationship between the current document and the linked document. rel is the English abbreviation of relationship.
rev reversed relationship HTML5 does not support this attribute.Defines the relationship between the linked document and the current document.
sizesNew HeightxWidth
any
Defines the size of the linked resource; only works when rel="icon".
target _blank
_self
_top
_parent
frame_name
HTML5 does not support this attribute.Defines where to load the linked document.
type MIME_type Specifies the MIME type of the linked document.


Global Attributes

The <link> tag supports global attributes. View the full attribute tableHTML Global Attributes。


Event Attributes

The <link> tag supports allHTML Event Attributes。


Related Articles

HTML Tutorial:HTML Styles

HTML DOM Reference Manual:Link Object

Other Extensions