Sub topic 1
What primary, neutral, and accent colours do
Prerequisites
Assume you know basic HTML and CSS, can edit a stylesheet, and understand hex and RGB colour values. This chapter uses HSL, a colour model that separates hue, saturation, and lightness.
Colour roles
A website palette works best when each colour has a job:
- Primary colour is the main brand colour. Use it for links, buttons, selected controls, and important actions.
- Neutral colours form the background, surfaces, text, and borders. They usually have low saturation.
- Accent colour adds emphasis to a small number of elements, such as a promotion, notification, or visual highlight.
These roles prevent every component from competing for attention. A primary colour should identify the interface. Neutral colours should provide structure. An accent should attract attention briefly.
Working in HSL
HSL represents a colour with three values:
- Hue is the position around the colour wheel, from 0 to 360 degrees.
- Saturation is the intensity of the colour. Zero percent is grey.
- Lightness controls how light or dark the colour appears.
HSL makes palette adjustments predictable. Keep the hue and saturation stable, then change lightness to create shades and tints.
:root {
--primary-500: hsl(220 80% 50%);
--primary-700: hsl(220 80% 34%);
--neutral-50: hsl(220 15% 97%);
--neutral-900: hsl(220 20% 12%);
}Choosing the primary colour
Start with the brand’s visual meaning and audience. Blue often suggests trust, while green can suggest growth, but these associations depend on context and culture. Check the colour on buttons, links, and large surfaces rather than judging it alone.
Choose one main hue first. Create lighter and darker versions by changing lightness. Keep a strong primary for actions, and reserve the most saturated version for places that need attention.
> callout tip > A colour is not accessible merely because it looks clear on your screen. Always test its contrast against the actual background.
Building the neutral colours
Neutrals should support the primary colour without becoming visibly colourful. Give them a slight hue tint so the interface feels coherent. Create at least a light surface, a border tone, body text, and a darker heading tone. Use the darkest neutral for important text and the lightest neutral for page backgrounds.
Exercise
Which role should normally provide the page background and body text?
Show answer
Neutral colours should provide both, because they create structure without competing with actions or highlights.