<link>

Term side of the Card.
Topic: Links
Unit title: <link>
Categories: Tag
Explanation side of the Card

Explanation: The element that is used to link external resources, such as stylesheets or icons, to the document. It's typically placed within the `<head>` element and is essential for including CSS, web fonts and other resources in a webpage.

Browser compatibility:
  • The chrome browser supports this feature starting from version 1.
  • The edge browser supports this feature starting from version 12.
  • The firefox browser supports this feature starting from version 1.
  • The safari browser supports this feature starting from version 4.
Availability: 

Example

Wronghtml
<link href="styles.css">
<link rel="shortcut icon" href="favicon.ico">
Righthtml
<link rel="stylesheet" href="styles.css">
<link rel="icon" href="favicon.svg" type="image/svg+xml">

Without rel the stylesheet is ignored, and rel='icon' is the standard keyword for favicons.

Common mistakes

  • Leaving out rel or misspelling it, so the stylesheet silently does not load.
  • Loading many small render-blocking stylesheets that could be one file.

Key points

  • Stylesheets use rel='stylesheet' with an href; type='text/css' is not needed.
  • Favicons use rel='icon' with the right type, and sizes when there are several.
  • Resource hints like preload and preconnect are in <head>, so the browser sees them early.

Interview questions

Does a stylesheet link block rendering?

Yes, stylesheets in <head> block rendering until loaded. A media attribute limits that to the conditions where the styles apply.

Can I load CSS without blocking first render?

Yes, a stylesheet whose media does not match, such as 'print', is still downloaded but does not block first render.

Analytics cookiesWe'd like to use analytics cookies to see which pages are useful. They're set only if you accept. Privacy Policy