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.
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.
CSSbackground: 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.
CSSbackground: linear-gradient(90deg in oklch shorter hue, red, cyan);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.
CSSbackground: 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
- OKLCH vs HSL vs sRGB: Understanding Wide-Gamut Display P3Compare HSL, sRGB Hex, Display P3, and OKLCH across perceptual lightness, gradient dead zones, gamut volume, and CSS progressive enhancement.
- One swatch in RGB, HSL, HSV, HWB and OKLabUse #336699 as a reference to check a color picker, a CSS declaration or a shader. Compare the same swatch in eight notations and find where round-trip errors start.
- Hex to OKLCH: Migrating Design Tokens to Tailwind CSS v4Step-by-step guide to upgrading Hex and HSL Tailwind v3 themes into CSS Color 4 @theme oklch() scales with perceptual brightness and Display P3 support.
- WCAG 2.2 Contrast Ratio vs APCA (Lc): Complete Color GuideCompare WCAG 2.2 relative luminance ratios (4.5:1) against modern APCA perceptual lightness contrast (Lc 60/75/90), dark-mode polarity, and CVD.