×

css · level 3 · unit 7 · lesson 1

  1. meet it
  2. guess first
  3. your turn
  4. fix it
  5. nailed it

Tap a green word if you get lost.

meet it

Primitive tokens hold values; semantic tokens say what they are for.

A splits its tokens in two. A holds a raw value: --teal-700: #0f766e. A names a job and points at a primitive: --action-bg: var(--teal-700). Components only read semantic tokens, so a rebrand changes one line.

Spacing works best as a scale: a few sizes that grow in steps. Store one base, --space: 4px, and build the rest with , which does sums inside a value: --space-3: calc(var(--space) * 3). Change the base and the whole scale follows.

<button class="btn">Book a table</button>
:root {
  --teal-700: #0f766e;
  --space: 4px;
  --action-bg: var(--teal-700);
  --space-3: calc(var(--space) * 3);
  --space-5: calc(var(--space) * 5);
}
.btn {
  padding: var(--space-3) var(--space-5);
  border: 0;
  color: white;
  background-color: var(--action-bg);
}

Press show my page to see it here.