lab() CSS Function
The lab() function defines a color in the CIE Lab color space by lightness and two color axes, a (green to red) and b (blue to yellow).
Description
The lab() CSS function defines a color in the CIE Lab color space. Instead of mixing red, green and blue light, Lab describes a color with a lightness value and two color axes: a, which runs from green (negative) to red (positive), and b, which runs from blue (negative) to yellow (positive). Lab was designed to match human vision, so equal changes in its values look like roughly equal changes in color.
Lightness ranges from 0 (black) to 100 (white), or as a percentage. The a and b values are signed numbers that usually stay within about -125 to 125, where 100% equals 125. When both are 0, the result is a neutral gray. Lab covers every color humans can see, so it can express colors far outside the sRGB gamut; the browser maps these to the nearest color the display can show. An optional alpha value can follow a slash.
.warm {
background-color: lab(65% 45 60); /* orange */
}
.cool {
background-color: lab(55% -30 -40); /* teal-blue */
}
.neutral {
background-color: lab(70% 0 0); /* mid gray */
}
/* Relative color: shift a color toward red */
.alert {
color: lab(from var(--text) l calc(a + 20) b);
}
lab() is often used as an interpolation space in gradients and color-mix() because it avoids the dull, grayish midpoints that sRGB mixing can produce. Its polar form is lch(), and an improved version of the same idea is oklab().
Interactive Demo
Syntax
lab() = lab( [ from <color> ]? [ <percentage> | <number> | none ]
[ <percentage> | <number> | none ]
[ <percentage> | <number> | none ]
[ / [ <alpha-value> | none ] ]? )
Values
- L (lightness)A <number> from 0 to 100 or a <percentage> from 0% to 100%. 0 is black and 100 is white.
- aA <number> or <percentage> for the green-red axis. Negative values are greener, positive values redder. 100% equals 125.
- bA <number> or <percentage> for the blue-yellow axis. Negative values are bluer, positive values more yellow. 100% equals 125.
- alphaOptional. An <alpha-value> after a slash (/) from 0 to 1, or a percentage.
Example
Browser Support
The following information will show you the current browser support for the CSS lab() function. Hover over a browser icon to see the version that first introduced support for this CSS function.
Desktop





Tablets & Mobile





