How to Create a CSS Gradient (Linear and Radial)

By Daniel · Updated July 2026

A gradient is a smooth blend between colours, and in CSS it is a background you can apply to anything. Building one visually and copying the generated code is far quicker than guessing angle and colour-stop values by hand.

Linear vs radial

A linear gradient blends along a straight line at an angle you choose — the default for buttons, headers and hero sections. A radial gradient blends outward from a point, like a soft spotlight. Most interface gradients are linear; radial is for glows and backgrounds.

How to build one

  1. Open the gradient generator.
  2. Pick your colours and drag the stops to position them.
  3. Set the angle, then copy the background CSS straight into your stylesheet.

Avoid the muddy middle

Blend two colours from opposite sides of the colour wheel — say red and green — and the midpoint turns a dull grey-brown. To keep a gradient vivid, use colours that sit near each other on the wheel, or add a third stop to guide the blend through a nicer intermediate colour.

Subtle looks professional: two shades of the same hue, or a small hue shift, almost always reads as more polished than a rainbow blend.

CSS Gradient Generator
Design a gradient visually and copy the CSS, in your browser.
Open the tool →

Common questions

What does the angle mean?

It sets the direction of a linear gradient. 90deg runs left to right, 180deg runs top to bottom.

Why does my gradient look muddy?

The two colours are far apart on the colour wheel, so the midpoint greys out. Use closer colours or add a middle stop.

Can I use more than two colours?

Yes. Add as many colour stops as you like and position each one along the line.

Is the tool private?

Yes, it runs entirely in your browser.

Keep reading

How to Generate a Color Palette · How to Check Color Contrast · How to Convert HEX to RGB