Document Metadata
HTML <link> element
Describes a relationship to an external resource, such as a stylesheet or icon. The rel value determines the processing rules. The example uses illustrative local asset paths; supply matching files before running it. Choose rel before choosing other attributes: a stylesheet is applied to the page, a preload schedules an anticipated fetch, and a canonical link identifies a preferred URL. Resource hints are not instructions to execute scripts. It accepts global HTML attributes; individual global features may be inapplicable or restricted.
Formal Syntax & Structure
html syntaxhtml
<link rel="stylesheet" href="site.css">Parameters & Attributes
| Name | Type | Description |
|---|---|---|
| href | URL | Specifies a link destination, resource URL or document base URL depending on the element. An anchor without href is not a normal navigable hyperlink. Relative URLs resolve against the document base URL. |
| crossorigin | enumerated: anonymous, use-credentials | Configures CORS settings for eligible resource requests. anonymous omits cross-origin credentials; use-credentials includes them. Server CORS headers must permit the request when needed. |
| rel | space-separated relationship keywords | Defines relationships between a document and a linked resource or navigation target. Valid tokens depend on the element; stylesheet, noopener and canonical have different purposes. |
| as | enumerated resource destination | Identifies what kind of resource a link preload will fetch, such as script, style, image or font. It must match the later request so the browser can reuse it. |
| media | media query list | Specifies conditions under which a resource or metadata applies, such as a stylesheet's target media or a picture source's viewport condition. |
| hreflang | BCP 47 language tag | Advises the language of a linked resource; it does not translate content or force a browser to use that language. |
| type | element-dependent keyword or MIME type | Selects an element-specific kind: input control state, button behavior, ordered-list numbering, script interpretation or resource media type. Consult the element's own allowed values. |
| sizes | responsive source size list or icon sizes | On responsive images, describes the expected display slot width used with width-descriptor candidates. On icon links, describes icon dimensions. The grammars differ. |
| imagesrcset | image candidate list | Provides responsive image candidates for a link preload. Match the final image's srcset and sizes so the preload selects the appropriate resource. |
| imagesizes | responsive source size list | Supplies source-size information for an image preload, corresponding to the sizes on the eventual image. Use with imagesrcset where width descriptors require it. |
| referrerpolicy | referrer policy keyword | Controls the referrer information sent with an eligible fetch or navigation. no-referrer omits it; strict-origin-when-cross-origin is a common default policy. It does not prevent all tracking. |
| integrity | subresource integrity hash metadata | Pins eligible external resources to an expected cryptographic digest. The browser rejects mismatches. Cross-origin use requires appropriate CORS support; regenerate the digest when the resource changes. |
| blocking | space-separated tokens | Requests eligible resource processing to block rendering; render is the relevant token. This can delay visible content, so use only when needed. |
| disabled | boolean | Disables supported controls or elements. Disabled form controls are generally not focusable, validated or submitted. The exact effect depends on the element; disabled="false" still disables. |
| fetchpriority | enumerated: high, low, auto | Hints relative fetch priority for eligible resources. It is not a guarantee and does not replace preloading or lazy loading. Reserve high for genuinely important resources. |
Return Value
HTMLLinkElement
Content model: Empty; this void element cannot contain children and must not have an end tag. No closing tag.
Working Example
Example Snippethtml
<!doctype html><html lang="en"> <head> <title>Guide</title> <link rel="stylesheet" href="site.css"> </head> <body> <p>Guide</p> </body></html>Browser Compatibility
Minimum supported versions across modern rendering engines
Chrome
1
Yes
Edge
12
Yes
Firefox
1
Yes
Safari
≤4
Yes
Opera
≤12.1
Yes
Checked desktop BCD snapshot: link element; individual rel values differ. Versions denote the recorded start of support (≤ means at least that early), not a guarantee of all behavior. Unresolved mirror and preview rows omitted.
HTML Living Standard