HTML <link> tag
Examples
Link to an external style file:
<link rel="stylesheet" type="text/css" href="theme.css">
</head>
try it"
Browser Support
All major browsers support <link> tag.
Tag definitions and instructions
<Link> tag defines the relationship between a document and an external resource.
<Link> tag most common use is linked style sheet.
Note: link element is an empty element, it contains attributes only.
Note: This element can only exist in the head section, but it can occur any number of times.
Differences between HTML 4.01 and HTML5
Some HTML 4.01 attributes are not supported in HTML5.
HTML5 adds "sizes" attribute.
Differences between HTML and XHTML
In HTML, <link> tag has no end tag.
In XHTML, <link> tag must be closed properly.
Attributes
New: HTML5 new property.
属性 | 值 | 描述 |
---|---|---|
charset | char_encoding | HTML5 不支持该属性。 定义被链接文档的字符编码方式。 |
href | URL | 定义被链接文档的位置。 |
hreflang | language_code | 定义被链接文档中文本的语言。 |
media | media_query | 规定被链接文档将显示在什么设备上。 |
rel | alternate archives author bookmark external first help icon last license next nofollow noreferrer pingback prefetch prev search sidebar stylesheet tag up |
必需。定义当前文档与被链接文档之间的关系。 |
rev | reversed relationship | HTML5 不支持该属性。 定义被链接文档与当前文档之间的关系。 |
sizes New |
HeightxWidth any |
定义了链接属性大小,只对属性 rel="icon" 起作用。 |
target | _blank _self _top _parent frame_name |
HTML5 不支持该属性。 定义在何处加载被链接文档。 |
type | MIME_type | 规定被链接文档的 MIME 类型。 |
Global Properties
<link> tag supports the global attributes, view complete the property sheet HTML Global Attributes .
Event Properties
<link> tag supports all HTML event attributes .
related articles
HTML Tutorial: HTML Style
HTML DOM Reference Manual: Link Object