index.html480px wideHello!1h1 {2 color: #ff6347;3 background: lavender;4 font-size: 3rem;5 padding: 0.5em;6 width: 50%;7}root font-size16pxbody width464pxcolor0 0 0backgroundnonefont-size32pxpadding0pxwidthauto#ff6347ff=25563=9947=71lavender3rem16px0.5em48px50%464px20px60px
Left: the stylesheet, style.css, one ruleRight: the browser, what it already knows, and the final valuesTokens: each value, and the base it is worked out from, on their wayLeft: the stylesheet, one rule for the heading. Right: the browser window, what the browser already knows (root font size, body width) and the final values it works out. Each colour becomes three light levels, whatever its spelling. Each length becomes CSS pixels: rem from the root font size, em from the element's own font size, % from the parent's width. When the root font size grows, the rem and em results follow and the % width does not. A real browser works out all of a rule's values at once, while it styles the page. The figure does them one at a time, in card order, so you can see what each one depends on.

Colours

  1. This rule styles the page's heading, h1. Its values come in two kinds: colours (color, background) and lengths with a unit (font-size, padding, width). The browser turns every one into something it can draw: light levels, or pixels.

Lengths and units

Change the base

What happens

;; step 1/9 · two-kinds
style.css
  h1 {
    color: #ff6347;
    background: lavender;
    font-size: 3rem;
    padding: 0.5em;
    width: 50%;
  }
colours   color, background
lengths   font-size, padding, width
the browser's starting values for h1:
  color 0 0 0 (black), font-size 2em = 32px, width auto

A real browser works out all of a rule's values at once, while it styles the page. The figure does them one at a time, in card order, so you can see what each one depends on. CSS names several stages of a value. A colour or an em length is turned into a fixed value early (the computed value); a percentage width stays a percentage until layout, when the browser knows the parent's width (the used value). The figure shows the final numbers the browser draws with.