Sub topic 11
Why equal numeric value does not look equally light
This chapter assumes you know HSV and HSL, the RGB channels, and basic Python. It explains why two colors with the same numeric lightness can look very different in brightness.
The problem
In HSL, hsl(60 100% 50%) is yellow and hsl(240 100% 50%) is blue. Both have lightness 50%. In HSV, both have value 100%. Yet yellow looks bright and blue looks dark.
The cause is how each model computes its number:
- HSV value is the largest of the red, green, and blue channels.
- HSL lightness is the average of the largest and smallest channels.
Neither formula asks how bright the eye finds each channel. Human vision responds most to green, less to red, and least to blue. A numeric "value" describes where the color sits in the model. It does not describe how bright the color looks.
Relative luminance
The sRGB standard defines a measure that does match perception better, called relative luminance. It runs in three steps:
- Convert each channel from 0–255 to 0–1.
- Undo the gamma curve. This turns the stored values into linear light.
- Add the channels with weights: 0.2126 for red, 0.7152 for green, and 0.0722 for blue.
Measuring it in Python
This script builds four fully saturated colors at HSL lightness 50%. It then prints the luminance of each.
import colorsys
def to_linear(c):
return c / 12.92 if c <= 0.04045 else ((c + 0.055) / 1.055) ** 2.4
def luminance(r, g, b):
return (0.2126 * to_linear(r)
+ 0.7152 * to_linear(g)
+ 0.0722 * to_linear(b))
hues = {"red": 0, "yellow": 60, "green": 120, "blue": 240}
for name, degrees in hues.items():
# colorsys uses HLS order: hue, lightness, saturation
r, g, b = colorsys.hls_to_rgb(degrees / 360, 0.5, 1.0)
print(f"{name:7} {luminance(r, g, b):.3f}")| Color | HSL lightness | Relative luminance |
|---|---|---|
| Red | 50% | 0.213 |
| Yellow | 50% | 0.928 |
| Green | 50% | 0.715 |
| Blue | 50% | 0.072 |
All four rows share the same lightness. Their luminance differs by a factor of about thirteen.
What this means in practice
- Hierarchy. Do not rely on equal HSL lightness to give two elements equal weight. A yellow button at
hsl(60 100% 50%)will dominate a blue one at the same setting. - Text legibility. White text on yellow is hard to read, even though yellow's numeric lightness is only 50%. Judge text and background pairs by luminance, which the contrast-ratio chapter builds on.
- Palettes. When you rotate hue to build a harmony, lightness will appear to change. Adjust it by eye or by measurement after you rotate.
- Quick check. Desaturate your design to grayscale. If two elements that should differ in weight look the same, or two that should match look different, adjust their lightness.
Some color spaces are designed so that equal lightness numbers look equally light. CIELAB has an L* channel, and OKLCH has an L channel. CSS supports oklch() in current browsers. These spaces are better when you want steady lightness across hues, for example in a data-visualization palette. They are not perfect, and very saturated colors can still fall outside the screen's range.
Exercise
A designer sets a heading to hsl(240 100% 50%) and a badge to hsl(60 100% 50%), expecting equal visual weight because both have 50% lightness. Which element will look lighter, and why does HSL fail to predict it?
Show answer
The yellow badge will look much lighter. HSL lightness is the average of the largest and smallest RGB channels, and it gives every channel equal weight. Perceived brightness depends mostly on green (weight 0.7152) and very little on blue (0.0722). Yellow contains full red and green, and blue contains only full blue. Their relative luminance is about 0.928 versus 0.072.