Red to purple gradient
A smooth red to purple 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, #ff0000, #ee1130, #dd1944, #cd1c52, #bc1d5e, #ad1b68, #9d1771, #8e0f79, #800080);
background: linear-gradient(90deg in oklab, #ff0000, #800080);Tailwind CSS v4
bg-linear-90/oklab from-[#ff0000] to-[#800080]Colors along the gradient
How red and purple 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 #bc1d5e in OKLab and #c00040 in sRGB, so any of them works.
| Blend in | Gradient preview | Middle color | Lightness | Chroma |
|---|---|---|---|---|
| OKLab | #bc1d5e | 52.4% | 0.195 | |
| OKLCH | #c40068 | 52.4% | 0.226 | |
| sRGB | #c00040 | 51.3% | 0.205 | |
| LCH | #ca0060 | 52.9% | 0.272 | |
| HSL | #c00060 | 52.1% | 0.21 |
Questions about this gradient
How do I make a red to purple gradient in CSS?
Use background: linear-gradient(90deg in oklab, #ff0000, #800080). 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 red and purple?
Blended in OKLab, the color halfway between red and purple is #bc1d5e. A plain sRGB blend gives #c00040.
How do I make a red to purple gradient in Tailwind CSS?
In Tailwind CSS v4 use the classes bg-linear-90/oklab from-[#ff0000] to-[#800080].