Let's be real: hex codes are pretty useless for humans. Nobody looks at #3b82f6 and immediately knows what color that is. But HSL 217, 91%, 60% makes complete sense: a cool blue hue, high saturation, and medium lightness. It's a format you can actually reason about.
HSL (Hue, Saturation, Lightness) is the ultimate bridge between color theory and code. Let's talk about how to master HSL to build highly responsive, programmatic design systems.
Programmatic Hover and Active States
The best part about HSL is that you can generate hover and active states mathematically. Instead of opening a color picker to find a slightly darker color, you can just subtract 10% from the lightness channel using CSS variables:
:root {
--brand-h: 217;
--brand-s: 91%;
--brand-l: 60%;
/* Programmatic resolution */
--color-brand: hsl(var(--brand-h), var(--brand-s), var(--brand-l));
--color-brand-hover: hsl(var(--brand-h), var(--brand-s), calc(var(--brand-l) - 8%));
--color-brand-active:hsl(var(--brand-h), var(--brand-s), calc(var(--brand-l) - 15%));
}
This is incredibly clean because if you ever need to change your brand color, you only have to update three numbers. Your entire action state matrix (hover, focus, pressed, active) scales automatically without any manual adjustments.
The Transition to OKLCH
While HSL is a solid step up, it has one major flaw: the human eye doesn't perceive lightness uniformly across different hues. Yellow and blue with the same 50% HSL lightness look wildly different in brightness. That's why modern CSS is transitioning to OKLCH, which corrects this perceptual gap. Getting comfortable with HSL math now makes transitioning to modern OKLCH CSS variables extremely natural.
