CSS chapters

Chapter 1 of 17

CSS rules and presentation

Try this in our CSS Compiler →

The idea

CSS describes the presentation of a document. A rule matches elements with a selector and applies declarations containing properties and values. The same HTML can have different layouts without changing its meaning. CSS is not a general-purpose instruction language and has no ordinary for loops or console output.

Worked example

body { font-family: sans-serif; }
h1 { color: teal; }

What to check

The heading changes colour only if the preview contains an h1. A selector matching nothing is valid but has no visible effect.

Practice task

Add a paragraph rule and compare it with the heading. Keep the HTML content meaningful without the styling.

Check your understanding

Explain the result in your own words before changing the example. Change one thing at a time, compare the result with your prediction, and keep the version that demonstrates the concept clearly.

Try it yourself

Output
Ctrl/Cmd+Enter runs · Ctrl/Cmd+S downloads the project · Local auto-save is always on