CSS Gradient Generator

Gradient type
Color stops

Drag a marker or use the arrow keys to move it (Shift moves by 10). Click the bar to add a stop there.

Presets

CSS

background-color: #FF996D;
background-image: linear-gradient(90deg, #FF7E5F 0%, #FEB47B 100%);

The background-color line is a solid fallback, the average color of the gradient. It shows while the gradient is not painted and helps when you check text contrast.

Download as PNG

Processed locally in your browser. Your input is not uploaded or saved by this tool.

About this tool

This CSS gradient generator builds linear, radial and conic gradients visually and writes the CSS for you. Add up to eight color stops, drag them along the bar, set the angle or the center, and watch the preview update. Presets give you a starting point, and every color field accepts HEX, rgb(), hsl() or CSS color names, including transparency.

The CSS output includes a solid background-color fallback calculated as the average of the gradient, followed by the background-image rule. You can also download the gradient as a PNG image at any size up to 4096 pixels, for example as a wallpaper, a placeholder or a slide background. A share link keeps the whole gradient.

How it works

A linear gradient changes color along a line. The angle sets its direction: 0 degrees points up, 90 degrees to the right and 180 degrees down. The line is just long enough for the first and last colors to reach the corners of the box. A radial gradient spreads from a center point as a circle or an ellipse that reaches the farthest corner, and a conic gradient sweeps colors around the center, starting at the chosen angle.

Each color stop has a color and a position from 0% to 100%. Between two stops the color blends smoothly; two stops at the same position create a hard edge. The stops are written in order of position, whatever order you added them in.

The fallback color is the average of the colors along the gradient line, weighted by how much of the line each part covers. The PNG export redraws the gradient on a canvas with the same geometry, so it matches the preview at the chosen size.

Example

The Sunset preset is a linear gradient at 90 degrees from #FF7E5F at 0% to #FEB47B at 100%, so it runs from coral on the left to peach on the right. Its CSS is background-image: linear-gradient(90deg, #FF7E5F 0%, #FEB47B 100%), with the fallback background-color: #FF996D, the average of the two colors.

Add a third stop at 50% and choose white, and the middle becomes a light band. Move that stop to 80% and the band shifts to the right, because the color now blends over 80% of the width on the left and 20% on the right.

Assumptions and limits

Colors blend in sRGB, as browsers do for gradients written with HEX, rgb() and hsl() colors. Gradients can have from 2 to 8 color stops with whole-number positions. Radial gradients use the default farthest-corner size, and the center is set in percent. Repeating gradients, color hints, multiple layered backgrounds and wide-gamut spaces such as OKLCH are not generated. PNG export needs canvas support for conic gradients, which current browsers have, and is limited to 4096 × 4096 pixels.

Frequently asked questions

How do I make a gradient in CSS?

Use a gradient function as a background image, for example background-image: linear-gradient(90deg, #FF7E5F 0%, #FEB47B 100%). Choose colors, positions and the angle in the generator, then copy the ready CSS, which also includes a solid fallback color.

What is the difference between linear, radial and conic gradients?

A linear gradient changes color along a straight line at an angle. A radial gradient changes color outward from a center point, as a circle or an ellipse. A conic gradient changes color around a center point, like the hands of a clock, which is useful for color wheels and pie-like shapes.

How do I make a hard edge between two colors?

Put two stops at the same position. For example, red at 50% followed by blue at 50% switches from red to blue without blending. This also creates stripes and flags with plain CSS.

Can a gradient fade to transparent?

Yes. Type a color with transparency in a stop's text field, for example rgb(0 0 0 / 0%) or #00000000. The generator keeps the alpha channel and writes it as an 8-digit HEX color in the CSS.

Why does the CSS include a background-color?

The background-color is shown while the gradient is not painted, for example in some email clients, in old browsers or when a stylesheet partly fails. Using the average color of the gradient keeps text readable in those cases and gives a good value to test contrast against.

Link with your values

Add these parameters to this page’s address to open it with the values filled in, for example to share a calculation or to link to it from an AI assistant. The result is calculated in the browser: the page HTML shows an example for the default values, and the tool sets the data-url-params attribute once the link’s values are applied.

ParameterValueIf omitted
presetPresetsone of: sunset, ocean, mint, peach, midnight, fire, spotlight, rainbowoptional
typeGradient typeone of: linear, radial, conicdefault linear
angleAngle (degrees)whole number; used with type = linear, conicdefault 90
shapeShapeone of: circle, ellipse; used with type = radialdefault circle
center_x_pctHorizontal centerpercent: 6.5 means 6.5%; allowed 0–100; used with type = radial, conicdefault 50
center_y_pctVertical centerpercent: 6.5 means 6.5%; allowed 0–100; used with type = radial, conicdefault 50
Color stops — rows numbered from 1, at most 8; every field of a row is needed
ParameterValueIf omitted
stop1Colorcolour: hex without # (3b82f6) or a CSS namerequired
stop1_position_pctPositionpercent: 6.5 means 6.5%; allowed 0–100optional

Examples

  • ?stop1=ff7e5f&stop2=feb47b&angle=135
  • ?shape=circle&center_y_pct=35&stop1=ffffff&stop2=93c5fd&stop2_position_pct=45&stop3=1e3a8a
  • ?type=conic&angle=90&stop1=ff0000&stop2=0000ff&stop3=ff0000
  • ?preset=ocean&angle=45

Write decimals with a point. Encode a space as %20, + as %2B, # as %23 and & as %26.

Result elements: [data-result-block="gradient"]