Skip to the page
css reference · attaching css

Linking a CSS file with <link>

type
HTML tag, lives in <head>
applies to
the whole document
inherits
n/a
common values
rel="stylesheet" href="path/to/file.css"

Where it goes

Inside <head>. Then the browser loads the styles before it draws the page, instead of showing an unstyled page for a moment first.

Example

<head>
  <link rel="stylesheet" href="style.css">
</head>

Open this example in the editor →

Common mistakes

  • A wrong or misspelled href. The browser says nothing. The styles just never show up.
  • Putting it at the bottom of <body> to "make the page load faster." It usually backfires: the page flashes unstyled, then jumps.

Related

Updated 24 October 2026. Practice it in the css route, or read more on MDN.