Sub topic 1
Describing a colour: hue, saturation, and lightness
Prerequisites
This chapter assumes you can name common colours and have used a colour picker in a design or image-editing tool. You do not need to know any colour theory. A little CSS helps for the code examples, but each one is explained.
By the end you will be able to describe any colour with three numbers, predict what happens when you change one of them, and avoid the most common mistakes in using them.
Why colour needs a vocabulary
Names like "light blue" or "dull red" are vague. Two people can picture different colours from the same words. Designers need a way to say exactly which colour they mean, and to say how two colours differ.
The usual answer is to split a colour into three independent attributes:
- Hue is the basic colour family, such as red, green or blue.
- Saturation is how intense or pure the colour is.
- Lightness is how light or dark the colour is.
Later chapters use these three attributes to build the colour wheel and its harmonies. Every harmony in this tutorial is defined by changing hue while holding the other two steady, so it pays to understand them well now.
Hue
Hue is the attribute that makes red different from green. It answers the question "which colour is this?" without saying anything about how bright or strong it is.
Hues form a continuous loop: red runs into orange, then yellow, green, blue, purple, and back to red. Because the sequence loops, hue is measured as an angle around a circle, from 0 to 360 degrees. In the HSL model used by CSS, the main reference points are:
| Hue angle | Colour name |
|---|---|
| 0 | Red |
| 60 | Yellow |
| 120 | Green |
| 180 | Cyan |
| 240 | Blue |
| 300 | Magenta |
| 360 | Red again (same as 0) |
Two details matter in practice. First, 360 and 0 are the same hue, so values wrap around. A hue of 390 is the same as 30, and a hue of -30 is the same as 330. Second, hue says nothing about whether the colour is pale or dark. Navy and sky blue share roughly the same hue. They differ in other attributes.
Saturation
Saturation describes how strong or pure a colour looks. A fully saturated colour is vivid. As saturation falls, the colour mixes with grey and looks more muted. At 0% saturation, no hue is visible at all and you get a pure grey, whatever the hue number says.
| Saturation | Appearance |
|---|---|
| 100% | Vivid, as intense as the model allows |
| 60% to 80% | Strong but comfortable on screen |
| 20% to 40% | Muted, dusty |
| 0% | Grey, with no visible hue |
High saturation grabs attention, which makes it useful for calls to action and warning signs, and tiring when used across large areas. Low saturation feels calm, quiet or sophisticated, which is why many interface backgrounds are only slightly saturated.
Lightness
Lightness describes how close the colour is to black or white. In HSL, 0% lightness is always black and 100% is always white, whatever the hue and saturation. A lightness of 50% gives the purest, most colourful version of a hue.
- Raising lightness above 50% moves the colour toward white and produces pastel tones.
- Lowering lightness below 50% moves the colour toward black and produces deep, dark tones.
Lightness carries most of the weight when you need readable text. Dark text on a light background works because the two lightness values are far apart, not because the hues differ. Chapter 13 returns to this when it covers contrast checks.
Putting the three together in CSS
CSS expresses all three attributes in the hsl() function. The order is hue (in degrees), saturation (percentage), lightness (percentage).
:root {
--hue: 210;
}
.vivid {
background: hsl(var(--hue) 90% 50%);
}
.muted {
background: hsl(var(--hue) 30% 50%);
}
.pale {
background: hsl(var(--hue) 90% 85%);
}
.deep {
background: hsl(var(--hue) 90% 20%);
}
.grey {
background: hsl(var(--hue) 0% 50%);
}All five classes use the same hue of 210, a blue. The .vivid class is a strong blue. The .muted class lowers saturation, giving a greyish blue. The .pale and .deep classes change only lightness, giving a light and a dark blue. The .grey class sets saturation to 0%, so the hue value has no visible effect.
Storing the hue in a custom property is a useful habit. You can change one number and retheme every colour that depends on it, which is the idea behind generating harmonies later in the tutorial.
Edge cases and common errors
Changing one attribute does not change the others, but it can look as if it does. Holding hue and saturation fixed and raising lightness makes a colour look less saturated to the eye, because it washes toward white. The number is unchanged. Your perception of it is not.
Hue values are circular, not a line. If you compute hue + 180 in code and get 390, you must wrap it with a modulo step. Browsers handle out-of-range hue in hsl() by wrapping, but other tools and your own arithmetic may not. A safe formula is ((h % 360) + 360) % 360, which also handles negative values.
Grey has no meaningful hue. When saturation is 0%, black, white and every grey share the same appearance whatever the hue. If you read a hue from a grey pixel, the number is arbitrary. This matters when you write code that extracts hues from images.
Equal HSL lightness is not equal perceived brightness. At 50% lightness, yellow looks far brighter than blue. HSL is a convenient description, not a model of human vision. Two colours with the same lightness number can have very different contrast against white. Always check contrast with a tool rather than trusting the lightness value.
HSL, HSB and HSV are different. Many design tools use HSB (hue, saturation, brightness), also called HSV. Its saturation and brightness values do not match HSL's saturation and lightness values. In HSB, 100% brightness with 100% saturation gives the pure colour, while in HSL that colour sits at 50% lightness. If you copy numbers between a design tool and CSS, convert them first.
The following table sets the two models side by side for one vivid blue.
| Model | Hue | Saturation | Third value |
|---|---|---|---|
| HSL | 210 | 100% | Lightness 50% |
| HSB | 210 | 100% | Brightness 100% |
Both rows describe the same colour, yet the third value differs. Matching the label, not just the number, is the habit to build.
A worked example: building a small palette from one hue
Suppose you want a calm interface in blue. Pick a base hue of 210, then vary only saturation and lightness to get a family of related colours.
:root {
--hue: 210;
--page: hsl(var(--hue) 20% 96%);
--surface: hsl(var(--hue) 25% 90%);
--accent: hsl(var(--hue) 70% 45%);
--text: hsl(var(--hue) 40% 15%);
}
body {
background: var(--page);
color: var(--text);
}
.card {
background: var(--surface);
}
.button {
background: var(--accent);
color: white;
}The page and surface colours use low saturation and high lightness, so they stay quiet. The accent uses higher saturation and mid lightness, so it stands out. The text uses very low lightness for strong contrast. All four share one hue, so they look related. This single-hue approach is a monochromatic scheme, which a later chapter covers.
Changing --hue to 150 turns the whole interface green with no other edits.
Summary of the model
- A colour is described by hue (an angle), saturation (intensity) and lightness (dark to light).
- Hue wraps at 360, so arithmetic on hues needs a modulo step.
- Saturation at 0% removes the hue entirely.
- Lightness of 0% and 100% give black and white regardless of hue and saturation.
- HSL numbers describe a colour but do not match perceived brightness, so contrast needs a separate check.
Exercise
A designer writes hsl(30 80% 50%) and wants a paler version of the same colour that keeps the same hue. They also want to compute the hue that is 180 degrees away from a base hue of 250. Which attribute should they change for the paler version, and what hue results from the 180-degree step after wrapping?
Show answer
They should raise lightness, for example to hsl(30 80% 80%), which keeps hue and saturation fixed. For the second part, 250 + 180 = 430, and wrapping with 430 % 360 gives a hue of 70.
Exercise
A colour has a saturation of 0% and a hue of 200. A colleague says it is a blue-grey. Is the colleague right, and why?
Show answer
No. At 0% saturation the colour is a pure grey, and the hue value of 200 has no visible effect. For a blue-grey the saturation must be above 0%, for example hsl(200 15% 50%).