Get the latest tech news

Oklch in CSS: why we moved from RGB and HSL (2024)


CSS Color Module 4 adds oklch(), and we gain P3 wide-gamut support, boost code readability, and improve developer-designer communication.

At the time of this writing in 2024, its ecosystem is still limited (for Figma we have the plugin but not official support), but we already have a palette generator, color picker, and many converters. On the other hand, OKLCH, LCH, HSL have values we can set that are much closer to the way people naturally think about colors. With CSS Custom Properties, we can define the:hover logic just once and then create many variants simply by changing the source color.

Get the Android app

Or read this on Hacker News

Read more on:

Photo of RGB

RGB

Photo of css

css

Photo of HSL

HSL

Related news:

News photo

Anchoreum: A game for learning CSS anchor positioning

News photo

Show HN: Puck 0.18 adds drag-and-drop for CSS grid and Flexbox

News photo

Show HN: Apple-like smooth corners for Tailwind CSS