How CSS thinks

The ideas underneath everything else: how a rule is built, how to choose elements precisely, how conflicts are settled, and how colours and sizes are written.

About 6 hours of study

Learning objectives

Lessons

  1. 1

    What CSS is and how it reaches a page

    How CSS separates a page's look from its content, how a rule is built, the three places styles can live, and why browsers skip what they cannot read.

  2. 2

    Selectors: choosing what to style

    Select elements by type, class, id, attribute and position in the page, and combine selectors precisely without writing fragile ones.

  3. 3

    The cascade, specificity and inheritance

    Why one CSS rule beats another, how specificity is counted, what inherits from parents, and how to resolve conflicts without reaching for !important.

  4. 4

    Colours, units and values

    Write colours in several formats, choose between px, em, rem, percentages and viewport units, and compute sizes with calc.

Module practice

Module quiz

1. A stylesheet has a misspelled property in the middle of a rule. What happens to the other declarations in that rule?
2. What is the difference between div p and div > p?
3. Which has the highest specificity?
4. A link inside a teal paragraph is still blue. Why?
5. Nested lists use font-size: 0.9em. What happens to the inner lists?
6. Which colour is the same as rgb(255 255 255)?

Boxes, text and decoration ›