How do you link a CSS file to an HTML document?

HighEasyCss
Quick Answer

Link CSS with <link rel="stylesheet" href="..."> inside the document head. Loading styles early prevents flashes of unstyled content, and most real bugs come from wrong paths, wrong placement, or render-blocking trade-offs you should debug in DevTools.

Answer

Direct answer

Use a <link> tag in the <head> of your HTML file:

HTML
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <link rel="stylesheet" href="styles.css">
</head>
                  

Part

Why it matters

rel="stylesheet"

Tells the browser this file is CSS.

href="styles.css"

Path to your stylesheet (relative or absolute).

Placed in <head>

Lets styles load before visible content paints.

Three things that must be correct.

Path examples

HTML
<!-- same folder -->
<link rel="stylesheet" href="styles.css">

<!-- inside /assets/css -->
<link rel="stylesheet" href="assets/css/main.css">

<!-- root-relative -->
<link rel="stylesheet" href="/css/main.css">
                  

Fast debugging checklist

  • Open DevTools Network tab and confirm the CSS file returns 200 (not 404).
  • Verify the path is correct for the current HTML location.
  • Hard refresh if caching hides a recent change.

Practical scenario
You split a prototype into multiple pages and move shared styles into one stylesheet so all screens stay consistent.

Common pitfalls

  • Wrong relative path after moving files.
  • Forgetting rel="stylesheet".
  • Linking CSS too late and causing FOUC.
Trade-off or test tip
One large CSS file is simpler but heavier upfront; route-level CSS can improve first paint but adds build complexity.

Still so complicated?

The <link> tag is your page's style import line. Without it, HTML renders with browser defaults.

Summary
  • Use <link rel="stylesheet" href="..."> in <head>.
  • Correct path + early loading are the two big correctness factors.
  • External stylesheets improve reuse and caching across pages.
Similar questions
Guides
Preparing for interviews?

Use the relevant interview-question hub first, then move into a concrete study plan before targeted company sets.