Linear gradients in new colour spaces

Week 420 was posted by Charanjit Chana on 2025-11-16.

Not strictly new, but I've not really dived into colour spaces in CSS much at all but have been looking at them recently because I knew they would provide smoother gradients for me.

Can I Use says there's over 90% support for Oklab and Oklch so definitely time to give them a go.

The first thing that stumped me was being able to specify the direction of a gradient and the colour space at the same time. Pretty simple actually because you can just chain them together:

background-image: linear-gradient(to top left in oklch, red, blue);

The above renders a gradient that starts with red in the bottom right and ends towards the top right in blue. The colour space is Oklch which is a lot more pleasing than the regular sRGB one that we're used to.

This post is really a reminder for myself. I've not relied on images for gradients in years but the CSS equivalent hasn't always been the best representation of a gradient but these get us to a really good place.


Tags:


Tweet WhatsApp Keep Upvote Digg Tumblr Pin Blogger LinkedIn Skype LiveJournal Like