HTML5 <link> Tag

Example

Link to an external style sheet:

<head>
<link rel="stylesheet" type="text/css" href="style.css" />
</head>
Code it Online »

Definition and Usage

The <link> tag defines the relationship between a document and an external resource.

The <link> tag is most used to link to style sheets.

Differences Between HTML 4.01 and HTML5

Some HTML 4.01 attributes are not supported in HTML5.

The "sizes" attribute is new in HTML5.

Tips and Notes

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

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

Attributes

Attribute Value Description
charset char_encoding Not supported in HTML5
href URL The target URL of the resource
hreflang language_code Defines the base language of the target URL
media media_query Specifies on what type of device the linked document or resource is optimized for
rel alternate
archives
author
bookmark
external
first
help
icon
index
last
license
next
nofollow
noreferrer
pingback
prefetch
prev
search
sidebar
stylesheet
tag
up
Specifies the relationship between the current document and the target URL. Use only if the href attribute is present
rev reversed relationship Not supported in HTML5
sizes heightxwidht
any
Defines sizes of the linked resource. Can be used when rel="icon".
target _blank
_self
_top
_parent
frame_name
Not supported in HTML5
type MIME_type like:
text/css
text/javascript
image/png
Specifies the MIME type of the target URL

Standard Attributes

The <link> tag also supports the Standard Attributes in HTML5.

Event Attributes

The <link> tag also supports the Event Attributes in HTML5.


Have Any Suggestion? We Are Waiting To Hear from YOU!

Your Query was successfully sent!