Introduction
Adding CSS to HTML
There are three ways to add CSS to a page.
1. External stylesheet (best)
Write your CSS in a separate .css file and link it from the <head>.
<link rel="stylesheet" href="styles.css">2. Internal stylesheet
<head>
<style>
p { color: gray; }
</style>
</head>3. Inline style
<p style="color: red; font-weight: bold;">Warning!</p>| Method | Good for | Downside |
|---|---|---|
| External | Real websites | One extra file to load (cached after the first visit) |
| Internal | Single-page demos | Can't be reused on other pages |
| Inline | Quick tests, emails | Hard to maintain, overrides everything |