Sub topic 5
Picking an accent colour
This chapter assumes you know basic HTML and CSS, can read hex and RGB values, and have met HSL (hue, saturation, lightness) in the previous chapters. You also have a primary colour and a neutral scale. Here you will add the third role: the accent.
What an accent is for
An accent colour is a second, contrasting colour used in small amounts to draw the eye to one thing. Typical uses are a highlighted badge, a "new" label, a secondary call to action, a chart series, or a selected-state marker.
The accent works because it is rare. If the primary colour marks "this is the brand" and the neutrals carry the structure, the accent says "look here". When you use it on every button, link and heading, it stops pointing at anything.
Three questions help you decide whether something deserves the accent:
- Is this the one thing on the screen I want noticed first or second?
- Does it need to stand out from the primary colour, not just from the neutrals?
- Would the page still work if this element used a neutral or primary instead?
If the answer to the first two is no, use the primary or a neutral.
Choosing a hue with the colour wheel
Because the palette is written in HSL, the hue is a number from 0 to 360 on a colour wheel. An accent is usually chosen by moving a fixed distance around that wheel from the primary hue. In the palette used in this tutorial, the primary hue is 220 (blue).
| Relationship | Hue offset | Result with primary hue 220 | Character |
|---|---|---|---|
| Analogous | ±30° | 190 (cyan) or 250 (indigo) | Calm and harmonious, but low contrast with the primary |
| Complementary | +180° | 40 (orange) | Strongest contrast, energetic |
| Split-complementary | +150° or +210° | 10 (red-orange) or 70 (yellow-green) | Strong contrast, a little less tense than a direct opposite |
| Triadic | +120° or +240° | 340 (pink-red) or 100 (green) | Lively, but harder to keep balanced |
The accent in the spine's palette is hsl(35 95% 50%). Hue 35 is within 5° of the complement of 220 (which is 40). It is a slightly warmer orange, which many designers prefer to the exact opposite because it reads as amber and sits more comfortably next to blue.
Computing the offsets
Doing this arithmetic by hand is error-prone because hue wraps around at 360. The following function returns the accent hues for each relationship and uses the modulo operator to wrap them.
function wrapHue(h) {
return ((h % 360) + 360) % 360;
}
function accentHues(primaryHue) {
return {
analogous: [wrapHue(primaryHue - 30), wrapHue(primaryHue + 30)],
complementary: [wrapHue(primaryHue + 180)],
splitComplementary: [wrapHue(primaryHue + 150), wrapHue(primaryHue + 210)],
triadic: [wrapHue(primaryHue + 120), wrapHue(primaryHue + 240)],
};
}
console.log(accentHues(220));
// analogous: [190, 250], complementary: [40],
// splitComplementary: [10, 70], triadic: [340, 100]
console.log(accentHues(350).complementary);
// [170] (350 + 180 = 530, wrapped to 170)The double modulo in wrapHue matters. In JavaScript, -10 % 360 is -10, not 350. Adding 360 before the second modulo fixes negative results.
Setting saturation and lightness
The hue only chooses the family. Saturation and lightness decide how loud the accent is, and they matter just as much.
- Saturation. An accent should usually be more saturated than your neutrals and about as saturated as the primary. The spine uses 95% for the accent against 80% for the primary, which makes the accent the most vivid colour on the page.
- Lightness. The mid-range (around 50%) gives the strongest chroma. Very light or very dark steps look washed out or muddy, so keep the base accent near the middle and let the scale handle the extremes.
- Perceived brightness. Equal HSL lightness does not mean equal perceived brightness. Yellow and orange at 50% lightness look much brighter than blue at 50%. You will see this when you check contrast later.
The orange accent illustrates the last point. hsl(35 95% 50%) looks bold against white, but white text on it fails the normal-text contrast threshold.
:root {
--primary-500: hsl(220 80% 50%);
--accent-500: hsl(35 95% 50%);
}
.badge {
background: var(--accent-500);
color: var(--neutral-900); /* dark text, not white */
padding: 0.125rem 0.5rem;
border-radius: 999px;
font-weight: 600;
}Dark text on the orange background is the correct pairing here. The check below shows why.
function channel(value) {
const s = value / 255;
return s <= 0.04045 ? s / 12.92 : Math.pow((s + 0.055) / 1.055, 2.4);
}
function luminance([r, g, b]) {
return 0.2126 * channel(r) + 0.7152 * channel(g) + 0.0722 * channel(b);
}
function contrastRatio(colorA, colorB) {
const a = luminance(colorA);
const b = luminance(colorB);
return (Math.max(a, b) + 0.05) / (Math.min(a, b) + 0.05);
}
// hsl(35 95% 50%) is approximately rgb(249, 152, 6)
const accent = [249, 152, 6];
console.log(contrastRatio(accent, [255, 255, 255]).toFixed(2)); // about 2.1
console.log(contrastRatio(accent, [18, 22, 37]).toFixed(2)); // about 8.2White on the accent gives roughly 2.1:1, well under the 4.5:1 needed for normal text. A near-black neutral gives roughly 8:1. The full contrast rules come in a later chapter. For now, treat this as a rule of thumb: bright, warm accents usually take dark text.
Using the accent sparingly
Restraint is the main skill. The accent should be about 10% of the visual weight of a page, which connects to the 60-30-10 guideline in the next chapter. A few practical rules keep you inside that budget.
- Use the accent for one kind of emphasis per page. If it marks both "new" badges and error states, it carries two meanings.
- Keep it off body text and long links. Large accent areas also tire the eye.
- Do not use the accent next to the primary at equal size. Two loud colours compete, and neither wins.
- Prefer small shapes (dots, badges, underlines, icons, a single highlighted card) over large fills.
:root {
--color-highlight: var(--accent-500);
}
.badge-new {
background: var(--color-highlight);
color: var(--neutral-900);
}
.nav-link[aria-current="page"] {
border-bottom: 3px solid var(--color-highlight);
}
.pricing-card.featured {
outline: 2px solid var(--color-highlight);
}Each rule points at the semantic name --color-highlight, not at --accent-500. If you later decide the accent should be teal, only one line in the token layer changes.
Common errors
- Choosing an accent that is too close to the primary. An analogous accent at 190 or 250 next to a 220 primary is hard to tell apart, especially for users with reduced colour discrimination. If you want a subtle accent, make sure lightness differs clearly too.
- Using red or green as the accent. These hues are already read as error and success. A red accent makes every highlight look like a problem. Reserve them for the semantic colours covered later.
- Relying on the accent alone to convey meaning. About 1 in 12 men has some form of colour-vision deficiency. Pair the accent with a label, icon, shape or underline.
- Putting white text on a bright accent. As the calculation showed, yellow, orange and light green accents fail with white text.
- Using the accent as a link colour. Links appear in running text, so they add up fast. Keep links on the primary and let the accent stay rare.
- Adding a second accent. One accent is enough for most sites. Add another only when you have a distinct, repeatable meaning for it.
Testing a candidate accent
A short checklist makes the choice repeatable.
- Compute candidate hues with
accentHuesfor your primary hue. - Set saturation close to or above the primary's, and lightness near 50%.
- Put it beside the primary at the sizes you will actually use.
- Decide whether text on it should be dark or light, then measure the contrast.
- Squint at the page or view it in greyscale. If the accent no longer stands out from the primary, make their lightness values further apart.
- Check the accent in dark mode, where bright colours often need a slightly lower saturation to avoid glowing.
Exercise
Your primary colour is hsl(160 70% 40%). Using the complementary relationship, what hue does the accent get? Then name one reason you might shift it by 5 to 10 degrees, and one check you must make before putting text on it.
Show answer
The complement is 160 + 180 = 340, a pink-red. You might shift it a few degrees (for example to 330 or 350) to get a warmer or cooler tone that sits better beside the green, or to avoid a red that reads as an error colour. Before placing text on the accent, calculate the WCAG contrast ratio between the text colour and the accent and confirm it is at least 4.5:1 for normal text (3:1 for large text), choosing dark or light text based on the result.
Exercise
A teammate uses the accent for body links, all buttons, and section headings, and says the page "feels busy". Explain why, and describe what you would change.
Show answer
The accent is no longer rare, so it no longer signals importance, and it competes with the primary colour. Move links and standard buttons to the primary colour, set headings in a neutral, and keep the accent for one kind of emphasis, such as a "new" badge or a single featured card. Reference it through a semantic token like --color-highlight so the change is made in one place.