ColorMar 31, 2026 ยท Updated Oct 13, 2026 ยท 3 min read

How to Mix Colors in CSS (and Color Theory)

How CSS color-mix() blends colors, measured: the same blue and yellow give grey in sRGB, a pinkish grey in Lab, teal in OKLCH and spring green in HSL. None of them gives paint-like green, and here is why.

๐Ÿงช
Try the Color Mixer
Free, no signup
โ†’
DG
Derek Giordano
Designer & Developer
In this guide
01The color-mix() Function02Same Two Colors, Six Spaces: Measured03Practical Uses

The color-mix() Function

color: color-mix(in oklch, #FF6B6B 60%, #0575E6);

color-mix() (CSS Color Module Level 5) blends two colors in a color space you name; percentages set the share of each, and a missing one takes the remainder. MDN's compatibility data lists it in Chrome and Edge 111, Firefox 113 and Safari 16.2, so every current browser supports it. The color space is not a detail: it decides the result.

Same Two Colors, Six Spaces: Measured

We asked Chromium for a 50/50 mix in each space and read the result back as sRGB (October 14, 2026; script in our test folder):

Spaceblue + yellow#FF6B6B + #0575E6red + lime
srgb#808080#8270a8#808000
srgb-linear#bcbcbc#bc70b6#bcbc00
lab#c289ac#b373a9#c8ac00
oklab#6cabc7#a17daf#d0a800
oklch#00cfbd#bc60d3#f99500
hsl#00ff80#c92efd#ffff00

Rectangular spaces (srgb, lab, oklab) average the coordinates, so opposite colors meet in the grey middle: blue and yellow give exactly #808080 in sRGB. Linear-light sRGB keeps the mix bright, closer to what blending light does. Polar spaces (oklch, hsl) go round the hue circle the shorter way and keep saturation, so blue and yellow become teal in oklch and spring green in hsl, and red with lime gives a vivid orange instead of olive.

No setting reproduces paint, where blue and yellow pigments make green, because pigments subtract light and screens add it. Pick the space for the result you want: oklab for even, natural-looking steps between two colors, oklch when you want to keep colors saturated through the middle, srgb only when you need to match older tools.

Practical Uses

The Color Mixer blends two colors in sRGB, linear sRGB, OKLab, OKLCH or HSL at any ratio and copies both the hex value and the matching color-mix() expression; its results match Chrome's own color-mix() to within half a step of 255.

Frequently Asked Questions

How do I mix colors in CSS?+
Use color-mix(in oklab, color1 50%, color2): name a color space, then two colors with optional percentages. oklab gives even, natural-looking blends; oklch keeps them saturated by going round the hue circle; srgb matches older tools.
What is the difference between additive and subtractive color mixing?+
Additive mixing (RGB) combines light โ€” used by screens. Subtractive mixing (CMYK) combines pigments โ€” used by printers. Mixing red + green gives yellow on screen but brown in paint.
Why does mixing blue and yellow in RGB give gray?+
Because in sRGB the two are opposite corners of the color cube: averaging (0,0,255) and (255,255,0) gives (128,128,128). Polar spaces go round the hue circle instead (teal in oklch, spring green in hsl), but no screen color space gives paint-like green, because paint mixing subtracts light while screens add it.
Try it yourself

Use the Color Mixer โ€” free, no signup required.

โšก Open Color Mixer
DG
Derek Giordano
Written by the creator of Ultimate Design Tools. BA in Business Marketing.