lch()

Term side of the Card.
Topic: Colors
Unit title: lch()
Categories: Function
Explanation side of the Card

Explanation: The color function that defines colors using the LCH (Lightness, Chroma, Hue) color space. It's a perceptually uniform color model, meaning that changes in the LCH values produce consistent changes in color perception, making it ideal for accessible and consistent color design.

Browser compatibility:
  • The chrome browser supports this feature starting from version 111.
  • The edge browser supports this feature starting from version 111.
  • The firefox browser supports this feature starting from version 113.
  • The safari browser supports this feature starting from version 15.
Availability: 

Example

Wrongcss
.tag {
  background: lch(0.7 40 250);
}
Rightcss
.tag {
  background: lch(70% 40 250);
}

In lch() lightness runs from 0 to 100, so a value under 1 renders almost black.

Common mistakes

  • Writing lightness as a value under 1, which gives near-black.
  • Reusing hsl() hue numbers, which point to different colors in lch().

Key points

  • Lightness is a percentage or a number from 0 to 100, and hue is an angle in degrees.
  • High chroma values that leave sRGB have a fallback declared first.
  • Blue palettes use oklch(), since lch() blues shift toward purple as lightness changes.

Interview questions

What is the difference between lch() and oklch()?

Both use lightness, chroma and hue. oklch() is built on Oklab, which keeps hues steadier, and its lightness runs from 0 to 1 instead of 0 to 100.

What is chroma in lch()?

Chroma is how vivid the color is, from 0 for gray upward. It has no fixed maximum, and very high values fall outside what screens can show.

Analytics cookiesWe'd like to use analytics cookies to see which pages are useful. They're set only if you accept. Privacy Policy