Skip to the color picker

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

Blend in

OKLab keeps the middle bright. sRGB is how old browsers blend and often turns gray in the middle.

Type
90°

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

7

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 inGradient previewMiddle colorLightnessChroma
OKLab#bc1d5e52.4%0.195
OKLCH#c4006852.4%0.226
sRGB#c0004051.3%0.205
LCH#ca006052.9%0.272
HSL#c0006052.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].