100% on-device · nothing uploaded
CSS gradient generator
Pick your colours, drag the stops, choose an angle, and copy the CSS. The preview is the real thing: what you see is exactly what the copied rule renders.
How to use it
- Choose linear or radial, then set the colours and their positions.
- Drag the angle for a linear gradient, or leave it at the default 90°.
- Copy the CSS and paste it into your stylesheet.
Why a blue-to-yellow gradient goes grey in the middle
A gradient is interpolation between stops, and by default CSS walks a straight line through sRGB. sRGB is not perceptually uniform, so the midpoint between two saturated, roughly opposite colours lands somewhere desaturated: blue to yellow passes through grey, red to green through muddy brown. Both endpoints are exactly the colours asked for; the path between them is the problem.
CSS Color 4 addressed this by letting the interpolation space be named. linear-gradient(in oklch, blue, yellow) interpolates through a perceptually uniform space and holds chroma along the way, while in hsl longer hue takes the long route round the wheel. Support landed across the engines during 2023, Safari first in 16.2. The default remains sRGB, and since an older engine discards the whole declaration rather than the unfamiliar keyword, a plain sRGB rule before it is the usual fallback.
Banding, and the tricks that hide it
An eight-bit-per-channel display offers 256 steps per channel. A gradient running 1,000 pixels between two dark, similar blues might traverse a dozen distinct values, giving each roughly eighty pixels of width — and the eye, unreasonably good at finding edges, reads those boundaries as stripes. Dark, low-contrast gradients over large areas are the worst case, which is why banding shows on hero sections rather than buttons.
Three things help. Extra stops add no steps but redirect the path away from the long flat stretches where bands form. A faint noise overlay dithers the boundaries, which is what design tools do before exporting. Shortening the run spends the available steps over fewer pixels each. What the copied CSS cannot do is manufacture precision the display lacks: banding is a property of colour depth, not of the rule.
Questions
Do I need vendor prefixes?
No. Every browser in use today supports unprefixed linear-gradient and radial-gradient; prefixes have been unnecessary for years.
What does the angle mean?
In CSS, 0deg points the gradient upwards and the angle turns clockwise — so 90deg runs left to right. That trips people up, because it is not the same convention as maths.
Can I use more than two colours?
Yes — add as many stops as you like and position each one along the line.
Updated 2026-07-20. Runs fully in your browser — nothing is uploaded.