lch()
The lch()
functional notation expresses a given color in the LCH color space. It has the same L axis as lab()
, but uses polar coordinates C (Chroma) and H (Hue).
Syntax
css
lch(29.2345% 44.2 27);
lch(52.2345% 72.2 56.2);
lch(52.2345% 72.2 56.2 / .5);
Values
Functional notation: lch(L C H[ / A])
L
-
A
<number>
between0
and100
or a<percentage>
between0%
and100%
that specifies the CIE Lightness where the number0
corresponds to0%
(black) and the number100
corresponds to100%
(white). C
-
A
<number>
or a<percentage>
where0%
is0
and100%
is the number150
. It is a measure of the chroma (roughly representing the "amount of color"). Its minimum useful value is0
, while its maximum is theoretically unbounded (but in practice does not exceed230
). H
-
A
<number>
or an<angle>
representing the hue angle. More details on this type can be found on the<hue>
reference. A
Optional-
An
<alpha-value>
, where the number1
corresponds to100%
(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 150
for the C
value.
Formal syntax
Examples
Adjusting lightness, chroma, and hue with lch()
The following example shows the effect of varying the L
(lightness), C
(chroma), and H
(hue) values of the lch()
functional notation.
HTML
html
<div data-color="blue"></div>
<div data-color="blue-light"></div>
<div data-color="red"></div>
<div data-color="red-chroma"></div>
<div data-color="green"></div>
<div data-color="green-hue"></div>
CSS
css
[data-color="blue"] {
background-color: lch(0% 100 240);
}
[data-color="blue-light"] {
background-color: lch(100% 100 240);
}
[data-color="red"] {
background-color: lch(50% 130 20);
}
[data-color="red-chroma"] {
background-color: lch(100% 30 20);
}
[data-color="green"] {
background-color: lch(50% 132 130);
}
[data-color="green-hue"] {
background-color: lch(50% 132 180);
}
Result
Adjusting opacity with lch()
The following example shows the effect of varying the A
(alpha) value of the lch()
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.
HTML
html
<div id="background-div">
<div data-color="red"></div>
<div data-color="red-alpha"></div>
</div>
CSS
css
[data-color="red"] {
background-color: lch(50% 130 20);
}
[data-color="red-alpha"] {
background-color: lch(50% 130 20 / 0.4);
}
Result
Specifications
Specification |
---|
CSS Color Module Level 4 # lab-colors |
Browser compatibility
BCD tables only load in the browser
See also
<color>
: For a list of all color notations- LCH colors in CSS: what, why, and how?
- Safari Technology Preview 122 release notes: includes
lch()
andlab()
colors