Language
日本語
English

Caution

JavaScript is disabled in your browser.
This site uses JavaScript for features such as search.
For the best experience, please enable JavaScript before browsing this site.

  1. Home
  2. HTML Tag Dictionary
  3. <link>

<link>

The <link> tag links external resources (such as CSS files and favicons) to an HTML document. It is placed inside <head> and is a void element — no closing tag is needed.

Syntax

<!-- Load a CSS file -->
<link rel="stylesheet" href="style.css?lang=en">

<!-- Specify a favicon -->
<link rel="icon" href="favicon.ico?lang=en" type="image/x-icon">

<!-- Load a print stylesheet -->
<link rel="stylesheet" href="print.css?lang=en" media="print">

<!-- Preload a resource -->
<link rel="preload" href="font.woff2?lang=en" as="font" type="font/woff2" crossorigin>

Attributes

AttributeDescription
relSpecifies the relationship between the document and the linked resource. This is the most important attribute and is required.
hrefSpecifies the URL of the linked resource.
typeSpecifies the MIME type of the resource. This can usually be omitted.
mediaSpecifies the media the resource applies to, such as screen or print.
crossoriginSpecifies how to handle cross-origin resource requests. Used when preloading fonts, for example.
asSpecifies the type of resource when using preload (rel="preload").

Common rel values

rel valueDescription
stylesheetLoads an external CSS file. This is the most commonly used value.
iconSpecifies the favicon shown in the browser tab.
canonicalTells search engines the canonical URL when duplicate pages exist.
preloadPreloads resources needed to render the page.
alternateSpecifies an alternate version of the page, such as a different language or print version.

Sample code

<head>
  <meta charset="UTF-8">
  <title>Sample Page</title>

  <!-- Load a CSS file (most common use) -->
  <link rel="stylesheet" href="css/style.css?lang=en">

  <!-- Specify a favicon -->
  <link rel="icon" href="favicon.ico?lang=en">

  <!-- Icon for smartphones -->
  <link rel="apple-touch-icon" href="apple-touch-icon.png?lang=en">

  <!-- Specify the canonical URL -->
  <link rel="canonical" href="https://example.com/page/">
</head>

Result

The CSS file is loaded and styles are applied to the page. The favicon appears in the browser tab and as the icon when the page is added to a smartphone's home screen.

Notes

The most common use of the <link> tag is loading CSS files with rel="stylesheet". To load multiple CSS files, write multiple <link> tags.

Because CSS files block page rendering, consolidating them into as few files as possible helps improve page load speed. JavaScript files, on the other hand, are typically placed at the end of <body> or loaded with the defer attribute on the <script> tag to defer loading.

Using rel="preload" lets you preload fonts, images, and other resources in parallel with HTML parsing, which can improve page load performance. When preloading fonts, be sure to include the crossorigin attribute. Without it, the font will be downloaded twice.

Browser Support

Chrome Chrome
49+
Supported in all versions
Firefox Firefox
57+
Supported in all versions
Safari Safari
18 or earlier ×
Edge Edge
80+
11 or earlier ×
IE IE
11 or earlier ×
Opera Opera
48 or earlier ×
iOS Safari iOS Safari
18 or earlier ×
Android Browser Android Browser
37+
4 or earlier ×
Chrome Android Chrome Android
36+
17 or earlier ×
Firefox Android Firefox Android
79+
3 or earlier ×

If you find any errors or copyright issues, please .