CSS Gradient Generator

Build a linear, radial or conic gradient by dragging colour stops, and copy the CSS.

Loading tool…

The gradient is rendered by your browser from the values on this page. Nothing is uploaded.

What the CSS Gradient Generator does

The CSS gradient generator on this page will build a linear, radial or conic gradient by dragging colour stops, and copy the CSS. Everything runs inside this page, so the work happens on your own device rather than on a server. It is most often used for building a hero or header background. For a second version of this CSS gradient generator, see FreeToolsWorld.org.

How to use it

  1. Drag the stops along the track to position them.
  2. Click anywhere on the track to add a stop, coloured to match the gradient at that point.
  3. Switch between linear, radial and conic, and set the angle.
  4. Copy the CSS.

How it works

Dragging stops is the only sensible interface for a gradient, because the relationship between a percentage and what you see is not something anyone holds in their head. Clicking an empty part of the track adds a stop already coloured to match the gradient at that point, so inserting a stop never changes the appearance until you deliberately move it.

The three gradient types do genuinely different things. Linear runs along a straight line at the angle you set, where 0deg points up and 90deg points right. Radial spreads outward from a centre point and is what you want for a glow or a spotlight. Conic sweeps around a centre like a clock face, which is how pie charts and colour wheels get drawn in pure CSS with no images at all.

Browsers interpolate between stops in sRGB, which is simple and occasionally ugly: a gradient between two saturated opposite hues passes through a desaturated grey in the middle, because the straight line between them in RGB space goes near the centre. The usual fix is adding an intermediate stop with the saturation you want, which is a good reason to build gradients visually rather than by writing two colours and hoping.

A gradient is a background image rather than a background colour, which has two practical consequences. It needs a fallback background-color for very old browsers, and it does not animate between values — transitioning a gradient requires either animating a background-position on an oversized gradient or crossfading two layered elements.

When to use it

  • Building a hero or header background.
  • Creating a subtle two-tone surface for a card or a button.
  • Making a conic gradient for a progress ring or a colour wheel.
  • Getting the exact CSS for a gradient you have designed elsewhere.

Common mistakes to avoid

  • Expecting a gradient to transition smoothly in CSS. It is a background image and does not animate between values.
  • Using two opposite hues with no intermediate stop, which passes through grey in the middle.
  • Forgetting a plain background-color fallback underneath.

Frequently asked questions

Why does my gradient look muddy in the middle?

Because browsers interpolate in sRGB, and the straight line between two opposite hues passes close to grey. Add an intermediate stop at the saturation you want and the muddiness disappears.

What angle is which in a linear gradient?

0deg points to the top, 90deg to the right, 180deg to the bottom. It is measured clockwise from up, which is different from the mathematical convention and catches people out.

Can I animate a CSS gradient?

Not directly — a gradient is a background image and CSS does not interpolate between two of them. The usual approaches are animating background-position on an oversized gradient, or crossfading two stacked elements.

Related tools

See all developer tools →