Sikau

CSS · Day 1 · about 20 min

How CSS works

Rules, selectors and declarations.

Clothes for your HTML

HTML says *what* things are. CSS says how they *look*: colours, spacing, fonts and layout. The same HTML can look completely different with different CSS.

A CSS rule

  • A rule = a selector (which elements) + a block of declarations in { }.
  • Each declaration is property: value; — don't forget the colon and semicolon.
  • In real sites, CSS lives in a file linked from the head: <link rel="stylesheet" href="styles.css">.

The rest of this lesson

  • Three places CSS can liveexplain
  • Classes: your main toolexplain
  • What turns green?predict
  • Parts of a rulematch
  • Your turnwrite code
  • Badge quizquiz
  • What you learnedrecap

Continue this lesson free — run real code in your browser

Continue with Google

See all 19 lessons of CSS