Lesson 16 of 55
HTMLUsing CSS with HTML – `<link>` and `<style>`
8 min
Course progress29%
What you'll learn
Keep these ideas in mind as you work through the lesson.
Lesson 16 of 55
HTML8 min
Keep these ideas in mind as you work through the lesson.
Two main ways to apply CSS:
<link rel='stylesheet' href='styles.css'> placed inside <head>.<style> block within <head> for page‑specific rules.<head>
<link rel='stylesheet' href='styles.css' />
<style>
.highlight { background: yellow; }
</style>
</head>
<style> – parsed after external CSS, can override it.style= – highest specificity, used sparingly.<link>You can conditionally load a stylesheet based on media features:
<link rel='stylesheet' href='print.css' media='print' />
The browser loads print.css only when printing or previewing.
rel='stylesheet'? ✅media attribute used where appropriate? ✅<style> only for critical CSS? ✅style= unless absolutely necessary? ✅If any answer is “no”, refactor your code.