Fixing the Grey Middle in CSS Gradients
Why blue to yellow goes muddy in sRGB, and two fixes: OKLCH interpolation and a mid stop.
By the TurantTools Dev team · Updated October 27, 2026 · 2 min read
A gradient from blue to yellow in plain CSS often passes through a muddy grey in the middle. That's because the browser blends the colours in sRGB, where the straight line between them dips in saturation.
/* Muddy middle */ background: linear-gradient(90deg, #2563eb, #facc15); /* Smoother: interpolate in OKLCH (modern browsers) */ background: linear-gradient(in oklch 90deg, #2563eb, #facc15); /* Works everywhere: add a mid stop by hand */ background: linear-gradient(90deg, #2563eb, #22c55e 50%, #facc15);
- Colour pairs on opposite sides of the colour wheel (blue–orange, red–green) are the worst for grey middles.
in oklchkeeps lightness even;in oklch longer huegoes the other way round the wheel.- Check text on gradients at their lightest point for contrast.