CSS Gradient Generator

Build a linear, radial or conic gradient with up to eight color stops and copy the CSS, which includes a solid-color fallback. Drag a stop’s position to 50% twice and you get a hard edge instead of a blend.

CSS Gradients Explained: Linear, Radial and Conic With Real Examples

Gradients used to mean exporting a background image from Photoshop and hoping it didn’t look blocky. Since around 2012, every major browser has supported CSS gradients, and today they are one of the most flexible tools in CSS. They can create soft backgrounds, sharp stripes, pie charts, borders and even patterns, all without a single image request.

Linear, radial and conic CSS gradients shown side by side

Gradients are images

The first thing to understand is that CSS gradients are generated images. That means they go in background-image (or the background shorthand), not background-color. You can layer several gradients, combine them with photos, and set their size and position like any other background image.

Linear gradients

A linear gradient blends colors along a straight line:

background: linear-gradient(135deg, #e8dcc4, #8a6d3b);

The first argument is the direction. Angles go clockwise from the top: 0deg points up, 90deg points right, 180deg (the default) points down. You can also use keywords like to right or to bottom left. Keyword corners adapt to the element’s shape, so to bottom right always ends exactly in the corner, while 135deg is a fixed angle that may not hit the corner on wide elements.

Color stops

After the direction come the color stops. Each can have a position:

linear-gradient(90deg, #e8dcc4 0%, #8a6d3b 60%, #141414 100%)

If you leave positions out, the browser spaces the colors evenly. Two useful extras:

  • Hard stops: give two colors the same position and the blend disappears: linear-gradient(90deg, red 50%, blue 50%) produces a sharp split. This is the basis of CSS stripes and patterns, which our CSS pattern generator uses.
  • Color hints: a bare percentage between two colors moves the midpoint of the blend: linear-gradient(red, 20%, blue) makes the transition happen earlier.

Radial gradients

Radial gradients spread outward from a center point:

background: radial-gradient(circle at 30% 40%, #e0a96d, #141414 70%);

You can choose circle or ellipse (the default) and a size keyword: closest-side, closest-corner, farthest-side or farthest-corner (the default). Changing the size keyword changes how far the gradient extends. Radial gradients suit spotlights, vignettes and soft glows, and stacking several of them creates mesh-style gradients.

Conic gradients

Conic gradients rotate around a center point, like the hands of a clock:

background: conic-gradient(from 0deg, #e8dcc4 0 25%, #8a6d3b 0 60%, #141414 0);

With hard stops, that’s a pie chart in one line. Without hard stops, conic-gradient(red, yellow, lime, aqua, blue, magenta, red) draws a color wheel. Conic gradients have been supported in all major browsers since 2020.

Linear, radial and conic side by side

TypeShapeKey parametersTypical uses
linear-gradientStraight bandsAngle or directionBackgrounds, overlays on photos, stripes
radial-gradientCircles or ellipsesShape, size, positionGlows, spotlights, vignettes, dots
conic-gradientSweep around a pointStart angle, positionPie charts, color wheels, checkerboards
repeating-*Repeats the stop patternSame as aboveStripes, rings, patterns

Repeating gradients

Each type has a repeating version. repeating-linear-gradient(45deg, #000 0 10px, #fff 10px 20px) creates diagonal stripes that tile across the element. repeating-radial-gradient makes concentric rings.

Gradients over images

A common pattern is darkening a photo so white text stays readable:

background:
  linear-gradient(rgb(0 0 0 / 0.6), rgb(0 0 0 / 0.1)),
  url(hero.jpg) center / cover;

The first layer is drawn on top. A gradient from 60% black at the top to 10% at the bottom keeps headlines readable without hiding the whole photo. Check the result with a contrast checker using the color behind the text.

The grey middle and color spaces

Gradients between two saturated colors on opposite sides of the color wheel, like blue and orange, often look dull in the middle. The browser interpolates in sRGB by default, and the straight line between blue and orange passes near grey.

Modern CSS lets you choose the interpolation color space:

background: linear-gradient(in oklch, blue, orange);

OKLCH keeps saturation through the middle; OKLab gives smoother perceived steps. Support arrived in Chrome and Safari in 2023 and in Firefox in 2024. For older browsers, add a solid fallback or an extra middle color stop. Our digital color mixing guide explains why this happens.

Gradient borders and text

Gradients can be used anywhere an image is allowed:

  • Gradient text: combine a gradient background with background-clip: text. See our gradient text generator.
  • Gradient borders: border-image: linear-gradient(...) 1 works but ignores border-radius. For rounded gradient borders, use two backgrounds with background-origin: border-box and a transparent border.

Performance and quality

CSS gradients are rendered by the browser on demand and are very fast. They weigh nothing over the network, scale perfectly to any screen density and can be changed with one line of CSS, which makes them ideal for theming.

Two caveats:

  • Banding. Subtle gradients over large areas can show visible steps on 8-bit screens. Adding a faint noise overlay hides this; see the noise texture generator.
  • Animation. Gradient values can’t be smoothly animated in most browsers unless you register custom properties with @property. A common workaround is to animate background-position on an oversized gradient.

Gradients that don’t look dated

  1. Keep background gradients subtle: two close tones of the same hue usually look more refined than a rainbow.
  2. Analogous colors (neighbours on the color wheel) blend most naturally.
  3. Always include a solid background-color fallback first.
  4. Use direction keywords (to bottom right) when the gradient must end in a corner.
  5. Test gradients on both light and dark mode if your site supports both.