CSS Gradient Generator

Make linear, radial and conic CSS gradients with presets and copy the code

Type
deg
Drag the dial or type. 0 = to top, 90 = to right, 180 = to bottom.
Colour stops (2 of 6)
  • %
  • %
The first line is a plain colour (the average of your stops) for very old browsers. Every current browser uses the second line.
Presetstap to load

Runs entirely in your browser. Nothing you type or upload is sent to us or stored.

Results are for general guidance. Please check anything important before relying on it. Terms of use

How to Use

  1. Choose Linear, Radial or Conic, or tap one of the Presets below the tool to start from a ready gradient.
  2. For linear and conic gradients, drag the dial or type the angle. For radial gradients, pick circle or ellipse. Radial and conic gradients also have sliders for the centre point.
  3. Edit the colour stops: drag the handles on the strip, or set each stop's colour and position in the list. Use Add stop for up to six colours, and the โœ• button to remove one.
  4. Press Random gradient when you want ideas, or Reverse colours to flip the gradient end to end.
  5. Watch the preview update, then press Copy CSS and paste the two lines into your stylesheet.

Gradients in plain CSS

A CSS gradient generator writes the code for a smooth blend between colours, so you don't need an image file for a background, a button or a hero banner. Gradients are drawn by the browser, scale to any screen size without going blurry, and cost nothing to download. Every current browser, including Chrome and Safari on cheap Android phones and older iPhones, supports all three types without vendor prefixes like -webkit-.

The three types

TypeWhat it doesGood for
linear-gradientColours change along a straight line at an anglePage backgrounds, buttons, banners
radial-gradientColours spread out from a centre point as a circle or ellipseSpotlight and glow effects, soft vignettes
conic-gradientColours sweep around a centre point like a clock handPie charts, colour wheels, loading rings

How the syntax works

linear-gradient(135deg, #ffe259 0%, #ffa751 100%)
radial-gradient(circle at 50% 40%, #fdfbfb 0%, #4b6584 100%)
conic-gradient(from 90deg at 50% 50%, #2563eb 0%, #2563eb 40%, #fde047 40%, ...)

In a linear gradient the angle sets the direction: 0deg runs from bottom to top, 90deg from left to right and 180deg from top to bottom. Each colour stop is a colour plus a position. Between two stops the browser blends smoothly. If two stops share the same position, you get a hard edge instead of a blend, which is how the Tiranga preset draws three clean bands of saffron, white and green.

For a conic gradient, from 90deg sets where the sweep starts, and the stop positions are shares of the full circle. The Pie preset uses hard edges at 40% and 75% to draw a three-slice pie chart with no image and no JavaScript.

Worked example

Say you want a warm button for a Diwali sale. Tap the Mango preset, which runs from yellow to orange at 135 degrees (top left to bottom right). The tool gives you:

background: #ffc555;
background: linear-gradient(135deg, #ffe259 0%, #ffa751 100%);

The first line is a plain colour, the average of your stops. A browser that can't draw gradients uses it and ignores the second line, which it doesn't understand. Everything modern uses the second line, which overrides the first.

Tips for gradients that look good

  • Two or three colours that sit near each other on the colour wheel blend cleanly. Opposite colours, like red and green, often turn muddy grey in the middle. Add a middle stop to steer the blend.
  • If text sits on top of the gradient, check the contrast at both ends, not only in the middle. White text that reads well on deep orange may vanish on pale yellow.
  • Large, very subtle gradients can show visible bands on some screens. A slightly stronger change of colour usually hides them.
  • To put a gradient over a photo, list it before the image: background: linear-gradient(...), url(photo.jpg);. A gradient from transparent to dark at the bottom makes caption text readable.
  • Use background-image instead of background if you only want to change the gradient and keep other background settings.

The random button uses your browser's secure random number generator to pick two or three colours and an angle in steps of 15 degrees. Nothing is sent anywhere, and the CSS is yours to use in any project.

Frequently Asked Questions

No. Linear and radial gradients have worked without prefixes in every major browser for years, and conic gradients work without prefixes in current Chrome, Edge, Firefox and Safari. The solid fallback colour covers anything older.

It's the direction the colours travel. 0deg goes from bottom to top, 90deg from left to right, 180deg from top to bottom and 135deg from top left to bottom right.

Give two neighbouring stops the same position. For example, saffron at 0% and 33.3%, then white at 33.3% and 66.6%, then green at 66.6% and 100% gives three solid bands. The Tiranga preset does exactly this.

Yes. List the gradient first and the image second, separated by a comma: background: linear-gradient(rgba(0,0,0,0), rgba(0,0,0,0.6)), url(photo.jpg). The first layer is drawn on top.

Because the two end colours sit on opposite sides of the colour wheel, so their mix is close to grey. Add a middle stop with a brighter colour, or pick end colours that are closer in hue.