CSS Gradient Generator

Build a CSS gradient with as many stops as you like and copy the rule, seeing the result as you change it.

Processed on your device — no upload

termiva gradient --linear
135°

Colour stops

  • 0%
  • 100%
62 chars

A gradient between two saturated colours passes through a muddy middle, because the interpolation runs through sRGB rather than around the colour wheel. If the midpoint looks grey, add a stop there in the hue you expected — that is what the extra stop is for.

type linearstops 2length 62 charsnothing uploaded

How to use it

  1. Choose the type.
  2. Set the colours and their positions.
  3. Copy the rule.

How it works

A CSS gradient is an image the browser draws rather than downloads. That is why it scales to any size without blurring, costs no network request, and can be animated by changing the numbers.

Linear runs along an angle, where 0deg points up and angles increase clockwise — so 90deg runs left to right and 180deg runs top to bottom. This trips people up because it is the opposite of the old vendor-prefixed syntax, where the angle described where the gradient came from.

Radial spreads outward from a point. A circle stays round whatever the shape of the box; an ellipse stretches to follow it, which is usually what you want for a wide banner.

Conic sweeps around a point like a clock hand. It is what pie charts and colour wheels are made of, and with hard stops — two stops at the same position — it produces flat segments rather than a blend.

A worked example

The muddy middle, and how to fix it. Put a saturated blue at 0% and a saturated yellow at 100%. The centre goes grey-green and lifeless. This is not a bug — the browser interpolates in sRGB, straight through the middle of the colour cube, and the middle of the cube is grey. Add a third stop at 50% in the hue you expected the transition to pass through and the whole gradient comes alive.

Hard stops make stripes. Set two stops to the same position, say both at 50%, and the colour changes instantly instead of blending. Repeat the pattern and you have a striped background with no image file — useful for progress bars, warning tape and the diagonal hatching that marks a disabled area.

A subtle gradient beats a flat colour on large surfaces. Two stops a few percent apart in lightness give a page background depth that a solid fill does not, and at that distance nobody consciously registers it as a gradient. The obvious two-vivid-colours gradient is a trend; this is not.

What to watch for. Text over a gradient has a different contrast ratio at each end. Check both extremes in the contrast checker, not just the midpoint — headline text that is legible at the top of a hero and invisible at the bottom is a common and entirely avoidable failure.

Questions

Which way does the angle go?

0deg points up and angles increase clockwise, so 90deg is left to right and 180deg is top to bottom. The old prefixed syntax used the opposite convention, which is why examples on the web disagree.

Why does the middle of my gradient look grey?

Because interpolation runs straight through sRGB, and the direct path between two opposing hues passes through grey. Add a stop in the middle in the hue you wanted.

How do I make stripes?

Put two stops at the same position. The colour changes instantly rather than blending, which is how every CSS stripe and pie segment is made.

Do gradients hurt performance?

No. They are drawn by the browser and cost no request. Animating one can be expensive, because it repaints; animating a transform or opacity over a static gradient is cheaper.

How do I fade to transparent?

End on an rgba value with zero alpha, and use the same colour rather than transparent. In Safari, transparent interpolates through transparent black and produces a grey haze.

Can I use a gradient on text?

Yes — set it as the background, then background-clip: text with a transparent text colour. Make sure the text is still selectable and readable at both ends.

What about conic gradients in older browsers?

They are supported in every current browser. If you need to reach very old ones, a radial gradient or an SVG is the fallback.

How many stops is too many?

Beyond four or five the effect stops reading as one gradient. If you need more, you probably want an image or an SVG mesh.