← All articles

CSS

Color and readable contrast

Use color consistently and keep text legible.

On this page

  1. Define a small palette
  2. Check contrast
  3. Do not rely only on color

Define a small palette

Choose a background, foreground, accent and muted color. CSS custom properties keep these choices consistent across pages.

Check contrast

WCAG AA generally calls for a 4.5:1 ratio for normal text and 3:1 for large text. Test the actual foreground and background pair.

Do not rely only on color

Pair color with meaningful labels, icons or text. An error message should identify the issue rather than simply turn a field red.

Example

:root {
  --text: #172638;
  --background: #ffffff;
  --accent: #175c9e;
}

Related reading