Why HSL needs a successor

HSL and HSLA are still the most practical way to specify colors in CSS. Hue runs 0–360 around the color wheel; saturation sits at 0% for grayscale and 100% for full color at that hue; lightness is "normal" at 50% and shifts toward white or black as it approaches 100% or 0%. That mental model is why HSL(a) remains easier to reason about than raw hex codes, which only a rare few developers can read at a glance. The format also maps naturally onto programmatic color control.

hsl(120, 100%, 40%)

The lightness mismatch

Patterns break down once HSL is used to build a system of colors. Brian Kardell has covered this in depth. Take three colors with the identical HSL lightness value: that does not mean their perceived lightness is equal. When they are the same on paper but look different to the eye, a color system built on that value misbehaves.

The Level 4 alternative: Lab and LCH

Lab and LCH, already specified as part of the CSS Level 4 color module, address exactly this. Adam Argyle has demonstrated the difference: matching colors, with the Lab lightness value displayed against its HSL counterpart, land much closer to what people actually perceive.

HSL vs LAB:: lightness 💡

Same colors from our tricky color poll, but this time I've shown LAB's version of the same color over top. Notice how much closer LAB's lightness value is to the results of our poll!

🎨 color spaces aren't all the same y'all! https://t.co/AIEs0amdWY pic.twitter.com/xkEguq3KZG

— Adam Argyle (@argyleink) December 3, 2019

Kardell frames this as a requirement for design systems rather than a nicety. Color spaces like Lab and LCH cover the full spectrum and carry qualities such as perceptual uniformness, so doing color math in those spaces is the widely agreed enabling feature for great color functions.

Browser-side effort

Implementation may be less of an obstacle than it sounds. In the Chrome bug ticket, Tab Atkins notes that lab(), lch() and gray() can all be eagerly converted into the existing color infrastructure. They introduce no fundamentally new concepts — just a better way to specify colors, tied more closely to how our eyes work than to how rgb pixels work. The conversion code is described as "some exponentials and a bit of matrix multiplication," backed by spec documentation.

Note that lab()/lch()/gray() can all be eagerly converted into our existing color infrastructure; they don’t introduce any fundamentally new concepts, they’re just a better way to specify colors, more closely associated with how our eyes actually function rather than being closely tied to how rgb pixels function.

The conversion functions to turn it into rgb are a little bit of code, but it’s just some exponentials and a bit of matrix multiplication, and it’s well-documented in the spec.

This should be a GoodFirstBug sort of thing, I think.