Please note, this is a STATIC archive of website www.w3schools.com from 05 May 2020, cach3.com does not collect or store any user information, there is no "phishing" involved.
THE WORLD'S LARGEST WEB DEVELOPER SITE

HTML <link> Tag


Example

Link to an external style sheet:

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

Definition and Usage

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

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


Browser Support

When used for style sheets, the <link> tag is supported in all major browsers. No real support for anything else.

Element
<link> Yes Yes Yes Yes Yes

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
crossorigin anonymous
use-credentials
Specifies how the element handles cross-origin requests
href URL Specifies the location of the linked document
hreflang language_code Specifies the language of the text in the linked document
media media_query Specifies on what device the linked document will be displayed
referrerpolicy no-referrer
no-referrer-when-downgrade
origin
origin-when-cross-origin
unsafe-url
Specifies which referrer to use when fetching the resource
rel alternate
author
dns-prefetch
help
icon
license
next
pingback
preconnect
prefetch
preload
prerender
prev
search
stylesheet
Required. Specifies the relationship between the current document and the linked document
sizes HeightxWidth
any
Specifies the size of the linked resource. Only for rel="icon"
title   Defines a preferred or an alternate stylesheet
type media_type Specifies the media type of the linked document

Global Attributes

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


Event Attributes

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


Related Pages

HTML tutorial: HTML Styles

HTML DOM reference: Link Object


Default CSS Settings

Most browsers will display the <link> element with the following default values:

link {
  display: none;
}