Text and Colour for CSSs
Text and colour in CSS cover typography and the colour system of a page. Typography properties include font-family, font-size, line-height and web fonts, while colour covers values like hex, rgb and hsl, opacity, gradients and backgrounds. Readable contrast and consistent scale make a design feel intentional.
Stage: Core CSS · Part of the CSS roadmap · Last reviewed 19 November 2026
What to learn in Text and Colour
- Set a readable font stack, size and line-height for body text
- Load a web font with @font-face and font-display
- Write colours in hex, rgb and hsl and know when each helps
- Layer a gradient and image as a background with background-size
- Check text contrast against a background using a contrast ratio tool
Text and Colour interview questions
What is the difference between em, rem and px units?
px is a fixed unit, em is relative to the element's own font size, and rem is relative to the root element's font size. Using rem for type and spacing respects user font settings and avoids the compounding that nested em values cause.
Why does line-height matter for readability?
Too tight and lines blur together, too loose and the eye loses its place. A unitless line-height around one and a half times the font size suits body text, and unitless values scale correctly with inherited font sizes.
Where Text and Colour fits in the CSS roadmap
Text and Colour belongs to the Core CSS stage (beginner level), which takes about 17 hours. Selectors and the box.