Sub topic 7
HSV and HSL: two ways to organize the same three ideas
This chapter assumes you know what hue, saturation, and value mean on their own, and that screens build color from red, green, and blue light. It also assumes you can read short Python and CSS snippets. Here you will see how two common models, HSV and HSL, arrange those three ideas differently, and why the same color gets different numbers in each.
Why two models exist
An RGB triple such as rgb(51 102 204) describes how much of each light to emit. It does not say "a medium blue, a bit muted." HSV and HSL fix this by re-describing the same RGB colors with a hue angle plus two other numbers.
Both models:
- Use the same hue angle, from 0 to 360 degrees, with the same meaning (0 red, 120 green, 240 blue).
- Cover exactly the same set of colors as RGB.
- Convert to and from RGB with simple formulas, so no color is gained or lost.
They differ in the other two numbers. HSV uses saturation and value. HSL uses saturation and lightness.
| Model | Third axis | Also called | Where you meet it |
|---|---|---|---|
| HSV | Value | HSB (brightness) | Photoshop and Figma color pickers, Python `colorsys` |
| HSL | Lightness | HLS | CSS `hsl()`, many design-token tools |
The formulas behind the difference
Take the largest and smallest of the red, green, and blue channels, each scaled to 0 to 1. Call them max and min. The two models use them differently.
- HSV: value is
max. Saturation is(max - min) / max. - HSL: lightness is
(max + min) / 2. Saturation is(max - min) / (1 - abs(2L - 1)).
Hue is computed the same way in both. The diagram traces one color through both paths.
The same blue is therefore HSV 220, 75%, 80% and HSL 220, 60%, 50%. Only the hue matches. Both descriptions are correct. The "saturation" label means something different in each model, so a saturation number is only meaningful once you know which model it belongs to.
Two shapes
Plot each model as a solid and the difference becomes visible.
- HSV is a cone (often drawn as a hexagonal cone). Black is the point at the bottom, where value is 0. The most vivid colors sit on the rim of the top face, where value is 100% and saturation is 100%. White sits at the center of the top face (value 100%, saturation 0%).
- HSL is a double cone, or bicone. Black is the bottom point and white is the top point. The most vivid colors sit on the widest circle at the middle, where lightness is 50% and saturation is 100%.
This leads to the main practical difference:
- In HSV, moving up the value axis at full saturation takes a color from black to the pure hue. It never reaches white. To get white you must also lower saturation.
- In HSL, moving up the lightness axis at any saturation goes from black, through the pure hue at 50%, to white at 100%. At 100% lightness the result is white whatever the hue and saturation are.
Same job, different sliders
Say you want a pale tint of the blue above. The HSL route is one slider: keep hue and saturation, raise lightness.
- HSL
220, 60%, 90%is aboutrgb(214 224 245).
The HSV route changes two numbers at once. You raise value a little and drop saturation a lot.
- The same color is HSV
220, 12.5%, 96%.
Now say you want a deep, rich version of the blue. In HSV you lower value and leave saturation alone, so the color darkens without turning gray. In HSL, lowering lightness at fixed saturation also works, but near black the available chroma shrinks, so the color can look dull unless you compensate.
Converting in code
Python's standard library includes both conversions. Note that colorsys returns HLS in the order hue, lightness, saturation, which differs from the usual HSL order.
import colorsys
r, g, b = 51 / 255, 102 / 255, 204 / 255
h, s_v, v = colorsys.rgb_to_hsv(r, g, b)
h2, l, s_l = colorsys.rgb_to_hls(r, g, b)
print(f"HSV: {round(h * 360)} {round(s_v * 100)}% {round(v * 100)}%")
print(f"HSL: {round(h2 * 360)} {round(s_l * 100)}% {round(l * 100)}%")This prints HSV: 220 75% 80% and HSL: 220 60% 50%. The hue is identical and the other two values differ.
You can also convert directly between the two models without going through RGB. The hue never changes, so only saturation and the third axis need work.
def hsv_to_hsl(h, s, v):
l = v * (1 - s / 2)
s_l = 0 if l in (0, 1) else (v - l) / min(l, 1 - l)
return h, round(s_l, 3), round(l, 3)
def hsl_to_hsv(h, s, l):
v = l + s * min(l, 1 - l)
s_v = 0 if v == 0 else 2 * (1 - l / v)
return h, round(s_v, 3), round(v, 3)
print(hsv_to_hsl(220, 0.75, 0.8)) # (220, 0.6, 0.5)
print(hsl_to_hsv(220, 0.6, 0.5)) # (220, 0.75, 0.8)The two special cases matter. At black (l = 0) and white (l = 1) the HSL saturation formula divides by zero, so the code returns 0.
What CSS gives you
CSS has hsl() built in but no hsv(). It does offer hwb(), which stands for hue, whiteness, blackness. It is a close relative of HSV: whiteness is (1 - S) * V and blackness is 1 - V. For HSV 220, 75%, 80% that gives whiteness 20% and blackness 20%.
.swatch-rgb { background: rgb(51 102 204); }
.swatch-hsl { background: hsl(220 60% 50%); }
.swatch-hwb { background: hwb(220 20% 20%); }All three rules paint the same blue. If your design tool shows HSB values and you need CSS, either convert with a formula like hsv_to_hsl above or use hwb().
Common errors
- Pasting HSB numbers into
hsl(). A picker showing220, 75%, 80%will not give you the same blue inhsl(220 75% 80%). That CSS color is a much paler blue. Always convert. - Assuming 100% saturation means "fully vivid." In HSL,
hsl(220 100% 95%)is almost white. In HSV, saturation 100% with value 30% is a very dark blue. Saturation describes purity relative to the model's own brightness axis. - Trusting hue at low saturation. When saturation is 0 the color is a gray, so any hue gives the same result. Near black or white in HSL, a small RGB change can swing the hue and saturation numbers wildly. Treat those regions as unstable.
- Treating the third axis as perceived brightness. Both models are simple rearrangements of RGB, not models of human vision.
hsl(60 100% 50%)(yellow) looks much lighter thanhsl(240 100% 50%)(blue) even though both have lightness 50%. A later chapter covers this gap.
Choosing between them
Use HSL when you write CSS, build scales of tints and shades from one hue, or generate themes by changing one number. Use HSV when you work in an image editor, pick colors by hand, or want "vivid versus dark" control without drifting toward white. For anything that must match human perception, such as evenly spaced steps or reliable contrast, neither model is enough. Later chapters cover contrast ratios and perceived lightness for those cases.
Exercise
A color picker reports HSV 120, 100%, 50%. Without code, what are the RGB channels (0 to 1) and the HSL values?
Show answer
Value is max, so max = 0.5. Saturation 100% means min = 0, so the color is rgb(0, 0.5, 0), a dark green. In HSL, lightness = (0.5 + 0) / 2 = 0.25 and saturation = 0.5 / (1 - abs(2 * 0.25 - 1)) = 0.5 / 0.5 = 1. The HSL value is 120, 100%, 25%.
Exercise
Why does hsl(0 100% 100%) render as white, while the HSV color 0, 100%, 100% renders as pure red?
Show answer
In HSL, lightness 100% is the white tip of the double cone, so hue and saturation no longer matter. In HSV, value 100% is only the brightest level. With saturation 100% the color sits on the rim of the cone's top face, which is the pure hue, here red. White needs saturation 0% in HSV.