The link
tag, or External Resource Link element, provides the relationship between the current document and an external resource, such as CSS style sheets, favicon, JavaScript file, etc.
The <link>
tag only contains attributes and does not wrap around anything.
<head>
<link rel="stylesheet" href="/assets/css/style.css">
</head>
crossorigin
Determines how the <link>
tag handles cross-origin requests. Possible values: anonymous
or use-credentials
.
href
Provides the URL from where the external resource is fetched.
hreflang
Identifies the language that the linked resource is in.
media
Identifies the media or device on which the linked resource will be displayed.
referrerpolicy
Determines which referrer information is sent when fetching the external resource. Possible values: no-referrer
, no-referrer-when-downgrade
, origin
, origin-when-cross-origin
, and unsafe-url
.
rel
Depending on the specified value, specifies the relationship between the linked resource and the current URL. This attribute is required. Possible values: alternate
, author
, dns-prefetch
, help
, icon
, license
, next
, pingback
, preconnect
, prefetch
, preload
, prerender
, prev
, search
, and stylesheet
.
sizes
When using rel="icon"
, this attribute provides the size of the external resource, in heightxwidth format.
title
Designates an alternate or preferred stylesheet.
type
Identifies the media type of the external resource.
Have a code example of <link>
? Submit a codepen.io demo and we'll showcase it here ↴