The lab() functional notation expresses a given color in the CIE L*a*b* color space. Lab represents the entire range of color that humans can see.
The lab() functional notation expresses a given color in the CIE L*a*b* color space. Lab represents the entire range of color that humans can see.
lab(29.2345% 39.3825 20.0664); lab(52.2345% 40.1645 59.9971); lab(52.2345% 40.1645 59.9971 / .5);
lab(L a b [/ A]) L is a <number> between 0 and 100 or a <percentage> between 0% and 100% that specifies the CIE Lightness where the number 0 corresponds to 0% (black) and the number 100 corresponds to 100% (white).a is a <number> between -125 and 125 or a <percentage> between -100% and 100%, specifying the distance along the a axis in the Lab colorspace, that is how green/red the color is.b is a <number> between -125 and 125 or a <percentage> between -100% and 100%, specifying the distance along the b axis in the Lab colorspace, that is how blue/yellow the color is.A (alpha) can be a <number> between 0 and 1, or a <percentage>, where the number 1 corresponds to 100% (full opacity). Note: Usually when percentage values have a numeric equivalent in CSS, 100% is equal to the number 1. This case is notable where 100% is equal to the number 100 for the L value and 125 for the a and b values.
The following example shows the effect of varying the lightness, a-axis, and b-axis values of the lab() function.
<div data-color="red"></div> <div data-color="red-a"></div> <div data-color="green"></div> <div data-color="green-b"></div> <div data-color="blue"></div> <div data-color="blue-light"></div>
[data-color="red"] { background-color: lab(100 125 125); } [data-color="red-a"] { background-color: lab(100 110 125); } [data-color="green"] { background-color: lab(75% -120 125); } [data-color="green-b"] { background-color: lab(75% -120 10); } [data-color="blue"] { background-color: lab(0 -120 -120); } [data-color="blue-light"] { background-color: lab(70 -120 -120); }
The following example shows the effect of varying the A (alpha) value of the lab() functional notation. The red and red-alpha elements overlap the #background-div element to demonstrate the effect of opacity. Giving A a value of 0.4 makes the color 40% opaque.
<div id="background-div"> <div data-color="red"></div> <div data-color="red-alpha"></div> </div>
[data-color="red"] { background-color: lab(100 125 125); } [data-color="red-alpha"] { background-color: lab(100 125 125 / 0.4); }
| Specification |
|---|
| CSS Color Module Level 4 # lab-colors |
| Desktop | Mobile | |||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|
| Chrome | Edge | Firefox | Internet Explorer | Opera | Safari | WebView Android | Chrome Android | Firefox for Android | Opera Android | Safari on IOS | Samsung Internet | |
lab |
111 | 111 | 111 | No | 97 | 15 | 111 | 111 | No | No | 15 | No |
<color> data type for a list of all color notationslab() and lch() colors.
© 2005–2023 MDN contributors.
Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.
https://developer.mozilla.org/en-US/docs/Web/CSS/color_value/lab