Building a simple colour palette for a small site

A small site can work with a handful of colours, each with one job. Start with the background and the text colour. Everything else is optional.
The jobs
- Background. The colour behind most of the page. It's usually light or dark and plain, so the text on it stays readable.
- Text. The colour of paragraphs. Pick foreground and background colours that have good contrast.1
- Accent. One colour for links, buttons and the odd highlight. Using it sparingly helps it stand out.
- Soft background. An optional second shade for boxes, table stripes or the footer. Check the text on it too.
- Status colours. Optional, for things like an error message. See the warning below.
You can add more. Each one means more pairs to test, so add a colour only if you can name its job. Be ready to test it against every background it will sit on. Keep it small.
Test every pair
A palette is only as good as its pairs. List each text colour with each background it sits on, then test them all.
| Pair | What to meet |
|---|---|
| Body text on background | At least 4.5:11 |
| Link colour on background | At least 4.5:1 for normal-size text1 |
| Button or icon against what's next to it | At least 3:11 |
| Text on a picture | Test where contrast is lowest2 |
There's no rounding up. A ratio just under the minimum fails.2 The steps for running a test are in the checking guide.
Don't let colour do the talking alone
Colour shouldn't be the only way you show something. Use another cue as well.3 A few ways:
- Underline links, so they don't depend on the accent colour alone.
- Add the word "Error" to a red message, not just the red.
- Make icons differ by shape as well as by colour.3
Be careful with the traffic-light idea of red for bad and green for good. People with red-green colour blindness have trouble telling red and green apart.3
A worked outline
Here's one way to write the palette down before you touch a stylesheet. The values are placeholders, not a recommendation.
- Background: a plain light colour.
- Text: a dark colour.
- Accent: one mid-tone colour, tested on the background.
- Soft background: a slightly different light colour, used for boxes.
Then test each pair. If the accent fails against the background, darken the accent. Don't lighten the background until it looks washed out. Simple.
When you change a colour
Change it in one place. If your site uses a single stylesheet, store each colour once and reuse it. Then a fix for one failing pair carries across the whole site.
After any change, run your checks again. Fonts matter just as much to how a page reads, so the font checklist is worth a look too.
Where the facts come from
- Color contrast, MDN Web Docs
- Understanding WCAG 2 Contrast and Color Requirements, WebAIM
- Use of color, MDN Web Docs