LOGBOOK

HELP

Quiz Entry - updated: 2026.06.20

What are the three ways to include CSS in an HTML document, and which is preferred?

CSS can live in an external .css file (recommended), in an internal <style> block inside the page's <head>, or inline on a single element via the style attribute.

1. External stylesheet — the normal case. The CSS sits in its own file, linked from the page's <head>:

<link rel="stylesheet" href="styles.css">

One file can style many pages, the browser caches it, and content stays cleanly separated from presentation.

2. Internal stylesheet. A <style> block in the <head> styles only that one page:

<style>
    h1, h2 { color: green; }
</style>

3. Inline styles. A style attribute on a single tag:

<p style="color: blue;">Text</p>

This is "quick and dirty": it scatters styling through the markup, overrides everything else, and quickly becomes impossible to track. Reserve it for genuine special cases (for example styles a script generates on the fly). For real projects, default to external stylesheets.

From Quiz: WEBT / CSS Basics | Updated: Jun 20, 2026