Sub topic 7
HSV and HSL: two ways to organize the same three ideas
This chapter assumes you know hue, saturation, and value as separate ideas and that screens mix red, green, and blue light. It also assumes you can read short Python and CSS snippets.
Same ideas, different geometry
HSV (hue, saturation, value) and HSL (hue, saturation, lightness) are both rearrangements of RGB. Neither adds colors. Both keep hue as an angle from 0 to 360 degrees, and the hue of a given color is the same in both models. They differ in how they define the other two axes.
- HSV sets value to the largest RGB channel. Value 100% means "as bright as this hue gets."
- HSL sets lightness to the average of the largest and smallest channels. Lightness 50% is the fully vivid color. Lightness 100% is always white, and 0% is always black.
Where they disagree
The two models give different numbers for the same pure red.
| Color | HSV | HSL |
|---|---|---|
| Pure red (255, 0, 0) | 0°, 100%, 100% | 0°, 100%, 50% |
| White (255, 255, 255) | any hue, 0%, 100% | any hue, 0%, 100% |
| Medium blue (51, 102, 204) | 220°, 75%, 80% | 220°, 60%, 50% |
The "saturation" values differ too. HSV saturation measures the gap between the largest and smallest channel, relative to the largest. HSL saturation measures the same gap relative to how far the color is from the middle gray. The same blue is 75% saturated in HSV and 60% in HSL. A saturation number is only meaningful when you know which model produced it.
Checking it in code
Python's colorsys module converts both ways. Its HSL function is named rgb_to_hls, and it returns lightness before saturation.
import colorsys
r, g, b = 0.2, 0.4, 0.8 # medium blue, channels from 0 to 1
h, s_hsv, v = colorsys.rgb_to_hsv(r, g, b)
h2, l, s_hsl = colorsys.rgb_to_hls(r, g, b)
print(round(h * 360), round(s_hsv, 2), round(v, 2)) # 220 0.75 0.8
print(round(h2 * 360), round(s_hsl, 2), round(l, 2)) # 220 0.6 0.5The hue is 220 in both lines. Only saturation and the third axis change.
Which one to use
Choose by the edit you want to make.
- HSL suits symmetric adjustments. Raising lightness moves toward white and lowering it moves toward black, with the pure color in the middle. That makes tints and shades easy to generate. CSS supports HSL directly, as in
hsl(220 60% 50%). - HSV suits "pick a hue, then choose how bright and how pure." Most color pickers show a square with saturation on one axis and value on the other, because the vivid color sits in a corner you can reach.
Shared limits
Neither model matches human perception. A yellow and a blue with the same HSL lightness can look very different in brightness, so lightness is not a reliable guide to legibility. A later chapter covers perceived lightness and contrast ratios.
Exercise
A color picker reports a color as HSV 30°, 100%, 100%. Would you expect its HSL lightness to be 100%? Why or why not?
Show answer
No. Value 100% with saturation 100% is the fully vivid color, with the largest channel at maximum and the smallest at zero. In HSL its lightness is the average of those two, so it is 50%. HSL lightness reaches 100% only for white.
Exercise
Why does converting a color from HSL to HSV leave the hue unchanged but alter the saturation number?
Show answer
Both models take hue from the relationship between the RGB channels, so it is the same angle. They define saturation against different references: the largest channel in HSV, and distance from middle gray in HSL. The same gap between channels gives different percentages.