Coding With Fun
Home Docker Django Node.js Articles Python pip guide FAQ Policy

HTML5 <link> tag


May 03, 2021 HTML5


Table of contents


HTML5 tags are used to establish a connection between the document and the externality to be used to obtain the appropriate resources for the document.

Link to an external style file:

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

Browser support

HTML5 <link> tag HTML5 <link> tag HTML5 <link> tag HTML5 <link> tag HTML5 <link> tag

All major browsers support the hashtag.


Label definition and instructions for use

The label defines the relationship between the document and external resources.

The most common use of labels is to link style sheets.


Note: The link element is an empty element and contains only properties.

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


The difference between HTML 4.01 and HTML5

Some HTML 4.01 properties are not supported in HTML5.

HTML5 has added the "sizes" property.


The difference between HTML and XHTML

In HTML, the label does not end the label.

In XHTML, the label must be turned off correctly.


Property

New: HTML5 new property.

Property Value Describe
charset char_encoding HTML5 does not support this property. Defines how characters are encoded for linked documents.
Href Url Defines the location of the document being linked.
hreflang language_code Define the language in which the Chinese document is library.
media media_query Specify what device the linked document will appear on.
rel alternate
archives
author
bookmark
external
first
help
icon
last
license
next
nofollow
noreferrer
pingback
prefetch
prev
search
sidebar
stylesheet
tag
up
Necessary. Defines the relationship between the current document and the linked document.
rev reversed relationship HTML5 does not support this property. Defines the relationship between the linked document and the current document.
sizes New Height x Width
any
The link property size is defined and only works on the property rel"icon".
target _blank
_self
_top
_parent
frame_name
HTML5 does not support this property. Define where to load the linked document.
type MIME_type Specifies the type of MIME for the linked document.


Global properties

The label supports global properties and views the full property sheet HTML global properties.


The event property

The label supports all HTML event properties.


Related articles

HTML tutorial: HTML style

HTML DOM Reference Manual: Link Object