Wulan’s dip-dyed cloth on the bamboo frame: write a linear, radial or conic gradient, the browser reads the value, and the gradient line, rings and rays of…
Why it matters
Gradients are in heroes, buttons, badges and charts. Knowing colour stops and the gradient line lets you make backgrounds with no image, plus tricks like hard lines, stripes and pie charts with conic-gradient, all pure CSS.
The key idea
A gradient is an image, and it is all about colour stops
Common mistakes
The gradient does not show though background-color is set A gradient is an image: use background or background-image. background-color: linear-gradient(...) is invalid, so the whole declaration is dropped.
A gradient "muddy" or grey in the middle sRGB interpolation averages each channel. Try linear-gradient(in oklch, …) for a brighter, more even blend, or add a stop in the middle.
Thinking conic is the same as radial radial radiates out from the centre (stop = a distance); conic sweeps round the centre (stop = an angle). Pie charts and colour wheels use conic.
Try it in this playground
Turn the linear angle to a few directions0deg up, 90deg right, 180deg down. Watch the gradient line’s length change too.
Switch to radial and conic radial radiates from a point; conic sweeps round a point (the basis of pie charts and colour wheels).
Put two stops of different colours at the same spot The blend disappears into a hard line (a hard stop): how stripes and flags are made without an image.
Open Grey in the middle, then change the colour spaceoklch or oklab keeps the middle bright. Compare them in the colour space strips.