What CSS does
Definition and purpose
CSS (Cascading Style Sheets) describes how HTML content is presented. HTML identifies the heading, paragraph and other content; CSS tells the browser how to display them. The same HTML can have a different appearance without changing its meaning.
A first heading
<!doctype html><html lang="en"> <head> <meta charset="utf-8"> <meta name="viewport" content="width=device-width, initial-scale=1"> <title>CSS practice</title> <style>h1 { color: navy; }</style> </head> <body> <h1 id="a">Garden journal</h1> <p id="b">Notes from spring.</p> </body></html>The heading becomes navy; the paragraph keeps its default text color.
Syntax and mental model
In h1 { color: navy; }, h1 selects headings of that type, color is the property, and navy is its value. A browser already supplies default styles; CSS changes selected aspects rather than replacing the document. Here <style> contains CSS; the next lesson explains where styles can live.
Style a notice
<!doctype html><html lang="en"> <head> <meta charset="utf-8"> <meta name="viewport" content="width=device-width, initial-scale=1"> <title>CSS practice</title> <style>h2 { color: green; } p { color: navy; }</style> </head> <body> <h2 id="a">Library hours</h2> <p id="b">Open at nine.</p> </body></html>Each rule targets a different HTML element type; the wording remains unchanged.
Common mistakes
Do not replace a heading with a paragraph merely to obtain a smaller font. Keep meaningful markup and adjust presentation. Do not rely on color alone to convey information.
Practice and next steps
After trying the examples, complete the linked coding exercise and review questions. Predict the result before running your code. Next lesson: Connect a stylesheet.
Check Your Understanding
Solidify your learning with the interactive assessment directly below this lesson.
Concept Quiz & Questions
What CSS does — knowledge check
Five questions on what css does.
What does CSS primarily describe?
What changes with h1 { color: navy; }?
A heading looks too large. What preserves its meaning?
Why is an unstyled page still visible?
Which rule colors paragraphs green?