Yellow to violet gradient
A smooth yellow to violet gradient in CSS, blended in OKLab so the middle stays clean. Change the angle, add colors and copy the code.
Colors
OKLab keeps the middle bright. sRGB is how old browsers blend and often turns gray in the middle.
CSS
background: linear-gradient(90deg, #ffff00, #fdf25b, #fbe47e, #f9d698, #f7c7ae, #f5b7c0, #f3a7d1, #f096e0, #ee82ee);
background: linear-gradient(90deg in oklab, #ffff00, #ee82ee);Tailwind CSS v4
bg-linear-90/oklab from-[#ffff00] to-[#ee82ee]Colors along the gradient
How yellow and violet blend in each color space
The same two colors give a different middle depending on the space the browser blends in. These are the exact colors at 50%. These two colors blend almost the same way in every space: the middle is #f7c7ae in OKLab and #f7c177 in sRGB, so any of them works.
| Blend in | Gradient preview | Middle color | Lightness | Chroma |
|---|---|---|---|---|
| OKLab | #f7c7ae | 86.5% | 0.065 | |
| OKLCH | #ffbca3 | 86.5% | 0.199 | |
| sRGB | #f7c177 | 84.2% | 0.11 | |
| LCH | #ffc1b7 | 87.7% | 0.216 | |
| HSL | #f34444 | 64.4% | 0.211 |
Questions about this gradient
How do I make a yellow to violet gradient in CSS?
Use background: linear-gradient(90deg in oklab, #ffff00, #ee82ee). Add a line before it with the sRGB version for very old browsers. Interpolation in OKLab works in all current browsers.
What color is halfway between yellow and violet?
Blended in OKLab, the color halfway between yellow and violet is #f7c7ae. A plain sRGB blend gives #f7c177.
How do I make a yellow to violet gradient in Tailwind CSS?
In Tailwind CSS v4 use the classes bg-linear-90/oklab from-[#ffff00] to-[#ee82ee].