CSS lch() Function
The CSS lch() function defines a color in the CIELAB color space using cylindrical coordinates: Lightness, Chroma, and Hue.
Introduced in CSS Color Module Level 4, lch() shares the exact same perceptually uniform color space as the lab() function, but represents colors using a familiar wheel-based model (similar to HSL) that is far more intuitive for developers and designers to pick and manipulate.
Syntax
The lch() function accepts three space-separated values representing Lightness, Chroma, and Hue, plus an optional alpha transparency channel:
Parameters
L(Lightness): A number from0to100or a percentage from0%to100%.0%represents black, and100%represents diffuse white.C(Chroma): A number or percentage representing the saturation or color purity. The minimum value is0(completely neutral gray). In theory, chroma is unbounded; in practice for display screens, it typically ranges from0to around150(or0%to100%, where100%corresponds to150).H(Hue): The hue angle on the color circle. Can be written as a unitless number (interpreted as degrees) or with an explicit angle unit such asdeg,grad,rad, orturn.0degpoints toward pinkish-red,90degtoward yellow,180degtoward bluish-green, and270degtoward blue.A(Alpha, optional): Preceded by a forward slash (/), specifying the transparency as a decimal between0and1(e.g.0.5) or a percentage between0%and100%.
Basic Examples
Here are some basic color examples specified using lch():
Using lch() in Style Sheets
The CSS specifications state that you can use lch() wherever a CSS <color> value is accepted. For example, you can use lch() to set the colors of text, backgrounds, and borders:
Specifying Transparency
An alpha channel can be added after a forward slash (/) to create semi-transparent colors:
lch() vs hsl()
While lch() and hsl() look similar because they both use Lightness and Hue, lch() solves major flaws found in hsl():
| Feature | hsl() |
lch() |
|---|---|---|
| Perceptual Lightness | Flawed: Yellow and blue both have 50% lightness, but yellow looks far brighter. | Uniform: 50% lightness in LCH has the exact same perceived brightness across every hue. |
| Color Gamut | Restricted to the 1990s sRGB color gamut. | Wide-gamut: Can display high-saturation colors on modern P3 displays. |
| Color Saturation/Chroma | Saturation is a percentage of sRGB gamut edge (varies wildly in intensity per hue). | Chroma is an absolute measure of perceived color purity. |
lch() vs lab()
lch() and lab() use the exact same underlying CIELAB color space. The only difference is how the color coordinates are described:
lab()uses Cartesian coordinates: You specify the color's position on two opposing color axes: a (green-red) and b (blue-yellow).lch()uses Polar coordinates: It converts those axes into a distance from the center (Chroma) and an angle on the circle (Hue).