Fix a muddy CSS gradient midpoint

Compare a CSS gradient midpoint in sRGB, OKLab and OKLCH using the same two stops. Choose a hue path or add a middle stop to control the transition.

2 min read · Updated 2026-11-22

Reproduce a gray midpoint with red and cyan

Place opaque red and cyan at the ends of an sRGB gradient. Halfway along the gradient, each encoded RGB channel is halfway between 0 and 255. The ideal midpoint is neutral gray, halfway between 127 and 128 on each channel. A sampled eight-bit value can differ from #808080 by one step per channel after conversion and rounding.

Reproduce a gray midpoint with red and cyan
CSS
background: linear-gradient(90deg in srgb, red, cyan);

Compare OKLab interpolation with an OKLCH hue path

Keep the endpoints and direction fixed while changing the interpolation space. OKLab follows a straight segment through its lightness and opponent-color coordinates. It can still pass close to neutral. OKLCH interpolates chroma and hue separately, so the path can visit saturated intermediate hues. Inspect the middle on the target screen because some intermediate colors can fall outside its gamut.

Compare OKLab interpolation with an OKLCH hue path
CSS
background: linear-gradient(90deg in oklch shorter hue, red, cyan);

Inspect gradient colors in the gradient generator

Set a middle stop for art direction

If the brief calls for a particular orange halfway across, add that color as a stop at 50%. A percentage hint alone moves the point of equal mixing and gives no guarantee of orange. Compare the quarter and three-quarter positions as well, especially if the gradient sits behind a label.

Set a middle stop for art direction
CSS
background: linear-gradient(90deg in oklab, red, #ff9800 50%, cyan);

Tools featured in this guide

Related formats

Frequently asked questions

How can I compare only the midpoint?

Use color-mix(in srgb, red 50%, cyan) as a flat swatch next to the gradient. Switch the interpolation space in both declarations to compare the same blend.

Will the longer hue path fix every dull midpoint?

It changes the route around the hue circle. Check the intermediate hues against the brief. An explicit stop gives tighter control over a particular color.

Authoritative Specifications & References

More color guides