Private archive copy · Unofficial site · Content copyright belongs to Runoob Tutorial and the original authors · View Original

HTML tag

HTML tag

Example

Linking to an external stylesheet:

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

Try it »


Browser support

Internet Explorer Firefox Opera Google Chrome Safari

All major browsers support tag.


Tag Definition and Usage Notes

The tag defines the relationship between a document and an external resource. The most common use of the tag is to link stylesheets.

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

Note: This element can appear only 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 added the "sizes" attribute.


Differences between HTML and XHTML

In HTML, the tag has no end tag.

In XHTML, The tag must be closed properly.


property

New: new attribute in HTML5.

property Value Description
charset char_encoding 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 what device the linked document will be displayed on.
rel alternate
 archives       

 author       

 bookmark       

 external       

 first       

 help       

 icon       

 last       

 license       

 next       

 nofollow       

 noreferrer       

 pingback       

 prefetch       

 prev       

 search       

 sidebar       

 stylesheet       

 tag       

 up | 必需。定义当前文档与被链接文档之间的关系。rel 是 relationship的英文缩写。 |

| rev | reversed relationship | Not supported in HTML5. Defines the relationship between the linked document and the current document. | | sizesNew | Heightx*Width
*any | Defines the size of the link icon; only works with rel="icon". | | target | _blank
_self
_top
_parent
frame_name | Not supported in HTML5. Defines where to load the linked document. | | type | MIME_type | Specifies the MIME type of the linked document. |


Global Attributes

The tag supports global attributes; see the full list in [HTML Global Attributes](/tags/ref-standardattributes.html).

Event attribute

The tag supports all [HTML Event Attributes](/tags/ref-eventattributes.html).

Related Articles

HTML Tutorial:HTML Styles

HTML DOM Reference Manual:Link Object