<link>
HTML <link> Tag
Instance
<!DOCTYPE html> <html> <head> <meta charset="utf-8"> <title>php中文网(php.cn)</title> <link rel="stylesheet" type="text/css" href="styles.css"> </head> <body> <h1>我是通过样式文件 styles.css 渲染后显示的。</h1> <p>我也是。</p> </body> </html>
Run Example»
Click the "Run Instance" button to view the online instance
Browser support
All major browsers support the <link> tag.
Tag definition and usage instructions
<link> The tag defines the relationship between the document and external resources. The most common use of the
<link> tag is to link style sheets.
Note: The link element is an empty element, it only contains attributes.
Note: This element can only exist in the head part, 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 does not have a closing tag.
In XHTML, the <link> tag must be closed properly.
Attributes
New: HTML5 new attributes.
Attributes | Value | Description |
---|---|---|
charset | char_encoding | This attribute is not supported in HTML5. 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 the device on which 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. |
rev | reversed relationship | ## This attribute is not supported in HTML5. Define the relationship between the linked document and the current document. |
New | HeightxWidth any | Defines the link attribute size, which only works for the attribute rel="icon". |
_blank | _self _top _parent frame_name | HTML5 does not support this attribute. Defines where to load the linked document. |
MIME_type | Specifies the MIME type of the linked document.