tadam logo

HTML5 <link> Tag

Example

Link to an external style sheet:
<link rel="stylesheet" type="text/css" href="/tryit/html/styles.css" />
The output of the code above will be:

Browser Support

The <link> tag is supported in all major browsers

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

New : New in HTML5.

AttributeValueDescription
charsetchar_encodingNot supported in HTML5
hrefURLSpecifies the URL of the resource
hreflanglanguage_codeSpecifies the language of the target URL
mediamedia_querySpecifies on what type of device the linked document or resource is optimized for
relalternate
author
help
icon
licence
next
pingback
prefetch
prev
search
sidebar
stylesheet
tag
Specifies the relationship between the current document and the target URL
revreversed relationshipNot supported in HTML5
sizesNewheightxwidth
any
Specifies the sizes (height and width) of the linked resource. Can be used when rel="icon"
target_blank
_self
_top
_parent
frame_name
Not supported in HTML5
typeMIME_type like:
text/css
text/javascript
image/gif
Specifies the MIME type of the target URL

Global Attributes

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

Event Attributes

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

Was this information helpful?
   

Comments