Command Palette

Search for a command to run...

Hectal
Back to the lesson: Topic 3.5 — Modern Colour
CSS · Example 3 of 4 Baseline 2024+

One brand colour, a whole button set (relative colours)

Change only --brand (try oklch(0.6 0.18 150) for green) and every derived colour follows.

oklch() describes colour by how light it looks, how colourful it is and its hue, reaching the vivid colours of modern screens; color-mix() blends two colours, relative colour syntax derives new colours from an existing one, and contrast ratios tell you whether text is readable.

Change the code and press Run (Ctrl+Enter). Predict what will happen first, then break it on purpose and read what changes. Your edits are saved and match the lesson page.

Ready for more? This phase has 5 hands-on exercises with automatic checks.

Practice questions

Write the code in the editor, run it, then open the model answer to compare.

01

Make three swatches .red, .green, .blue with the same oklch lightness 0.65 and chroma 0.15, and a fallback hex for each.

02

Given --brand: #0f766e, write a .callout whose background is a 12% tint of the brand mixed with white and whose border is the brand colour 0.1 darker in oklch.

Explain it without notes

01

What do the three numbers in oklch() mean, and what does it fix compared with hsl()?

02

What is a colour gamut, and what happens when you use a colour the screen can't show?

03

Show two uses of color-mix() and explain why the colour space matters.

04

What are the WCAG contrast thresholds, and how is the ratio calculated?

One brand colour, a whole button set (relative colours) Baseline 2024+

Preview

Press Run to see the page.

Console

Nothing logged yet.