<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

1000.png

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.

sizes Defines the link attribute size, which only works for the attribute rel="icon". target_blanktypeSpecifies the MIME type of the linked document.

Global attributes

<link> tag supports global attributes, see the complete attribute table HTML global attributes.


Event attributes

<link> tag supports all HTML event attributes.


Related Articles

HTML Tutorial: HTML Styles

HTML DOM Reference Manual: Link Object


AttributesValueDescription
charsetchar_encoding This attribute is not supported in HTML5. Defines the character encoding of the linked document.
hrefURL Defines the location of the linked document.
hreflanglanguage_code Defines the language of the text in the linked document.
mediamedia_querySpecifies the device on which the linked document will be displayed.
relalternate
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.
revreversed relationship## This attribute is not supported in HTML5. Define the relationship between the linked document and the current document.
NewHeightxWidth
any
_self
_top
_parent

frame_name
HTML5 does not support this attribute. Defines where to load the linked document.
MIME_type