DevTools Pro · All tools · About

CSS Gradient Generator

About the CSS Gradient Generator

This CSS gradient generator writes the background code for linear, radial and conic gradients while you adjust colors, stop positions and the angle. The preview redraws on every change, and the copied rule includes a solid-color fallback line so older browsers still get a background.

CSS gradient syntax explained

A gradient is an image, so it goes in background or background-image, not background-color. The generator outputs one of three functions: linear-gradient(), radial-gradient() or conic-gradient().

Each function takes a list of color stops such as #ff0000 0%, #0000ff 100%. The percentage sets where along the gradient that color is fully reached, and the browser blends between neighboring stops.

A typical result looks like background: linear-gradient(90deg, #ff0000 0%, #0000ff 100%);.

Linear vs radial vs conic gradients

Linear gradients blend along a straight line set by an angle. Radial gradients spread outward from the center; this tool uses radial-gradient(circle, ...), so the angle slider is hidden for that type.

Conic gradients sweep colors around a center point like a clock hand. The angle sets where the sweep starts, written as conic-gradient(from 45deg, ...). They are useful for pie charts, color wheels and spinners.

How gradient angles work

In CSS, 0deg points up, so a 0° linear gradient runs from bottom to top. 90deg runs left to right, 180deg runs top to bottom and 270deg runs right to left.

The to right keyword is the same as 90deg. Angles are measured clockwise, which differs from the counterclockwise convention in math class.

Hard edges and stripes with color stops

Putting two stops at the same position creates a hard line instead of a blend. For example, #ff0000 50%, #0000ff 50% splits the box into two solid halves.

Spreading stops far apart gives soft transitions. Two to four stops usually look cleanest, and extra stops are best for deliberate effects such as stripes or bands.

How to Use the CSS Gradient Generator

  1. Choose a Gradient Type: Linear, Radial or Conic.
  2. Drag the Direction slider (or Start angle for conic) to set the angle from 0° to 360°.
  3. Under Color Stops, pick each color with the swatch or type a value, then drag its Position slider. Use the + button to add a stop and the trash icon to remove one.
  4. Use the up and down arrows to swap colors between neighboring stops, or the reverse button to flip the whole gradient.
  5. Check the Gradient Preview and the Sample Text banner, then click the copy button in CSS Output.

Frequently Asked Questions

Why does my gradient not show when I use background-color?
Gradients are images in CSS, so they only work in background or background-image. Setting them on background-color is invalid and ignored.
Which direction is 0deg in a CSS linear gradient?
0deg points to the top, so the gradient starts at the bottom and ends at the top. 90deg goes left to right.
How do I make a sharp line between two colors?
Give both colors the same position, for example 50% and 50%. The browser then switches colors instantly instead of blending.
Do conic gradients work in all browsers?
conic-gradient() is supported in all current versions of Chrome, Edge, Firefox and Safari. The generated fallback line covers very old browsers.
Can I use colors with transparency?
Yes. Type an rgba(), hsla() or 8-digit HEX value into a stop's text field. The color swatch only edits 6-digit HEX, but any valid CSS color typed in the field is used in the output.
Is anything I create stored or uploaded?
No. The gradient is built in your browser and nothing is sent to a server. Copy the CSS before leaving the page, because settings are not saved.

Related tools