Example
Link to an external style sheet:<link rel="stylesheet" type="text/css" href="/tryit/html/styles.css" />
Browser Support
The
<link> tag is supported in all major browsersDefinition and Usage
The <link> tag defines the relationship between a document and an external resource.
The <link>
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.
| Attribute | Value | Description |
|---|---|---|
| charset | char_encoding | Not supported in HTML5 |
| href | URL | Specifies the URL of the resource |
| hreflang | language_code | Specifies the language of the target URL |
| media | media_query | Specifies on what type of device the linked document or resource is optimized for |
| rel | alternate author help icon licence next pingback prefetch prev search sidebar stylesheet tag | Specifies the relationship between the current document and the target URL |
| rev | reversed relationship | Not supported in HTML5 |
| sizesNew | heightxwidth 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 |
| type | MIME_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?

