Gradients

Functions that generate an <image> of smoothly changing colour, so they work anywhere an image does: background-image, border-image, mask-image and list-style-image. A gradient has no natural size and fills whatever box it is painted into. The colours inside are any colour function; other image functions such as image-set() are under Shapes & images.

Gradients

linear-gradient()

Colours that change along a straight line. The line's direction is an angle (0deg points up, 90deg right) or a side or corner such as to right or to top left; the default is to bottom.

Syntaxlinear-gradient( [ <linear-gradient-syntax> ] )
Returns<image>
Supportlinear-gradient(): Chrome 26 · Firefox 16 · Safari 7
Interpolation colour space (in): Chrome 111 · Firefox 127 · Safari 16.2
Speccss-images-3

<linear-gradient-syntax> is [ [ <angle> | <zero> | to <side-or-corner> ] || <color-interpolation-method> ]? , <color-stop-list>. The colour stop list is shared by every gradient on this page:

PartEffect
redA colour stop. Stops without positions are spread evenly.
red 20%A stop at a set position along the gradient line.
red 20% 40%Two positions: a solid band of that colour. Two stops at the same position give a hard edge.
30% between two stopsA colour hint: moves the midpoint of the transition between its neighbours.
in oklchThe colour space the transition is calculated in. The default is oklab; legacy sRGB colours such as hex and rgb() blend in srgb unless you set one.
background: linear-gradient(to right, #ffd21a, #ff5a1f);
background: linear-gradient(135deg in oklch, oklch(80% 0.15 90), oklch(60% 0.2 300));
background: linear-gradient(transparent 50%, rgb(0 0 0 / 0.6));
A left-to-right fade, a diagonal blend calculated in OKLCH, and a darkening scrim over the lower half.

radial-gradient()

Colours that radiate outwards from a centre point as a circle or an ellipse. You can set the shape, its size (a length, two lengths for an ellipse, or a keyword such as closest-side or farthest-corner) and the centre with at <position>.

Syntaxradial-gradient( [ <radial-gradient-syntax> ] )
Returns<image>
SupportChrome 26 · Firefox 16 · Safari 7
Speccss-images-3

<radial-gradient-syntax> is [ [ [ <radial-shape> || <radial-size> ]? [ at <position> ]? ] || <color-interpolation-method> ]? , <color-stop-list>. The default is an ellipse that reaches the farthest corner, centred in the box.

background: radial-gradient(circle at 30% 20%, #fff8, transparent 40%);
A soft highlight towards the top left.

conic-gradient()

Colours that change around a centre point, like the hands of a clock. Stops are positioned by angle or percentage of a full turn. Useful for pie charts and colour wheels.

Syntaxconic-gradient( [ <conic-gradient-syntax> ] )
Returns<image>
SupportChrome 69 · Firefox 83 · Safari 12.1
Speccss-images-4

<conic-gradient-syntax> is [ [ [ from [ <angle> | <zero> ] ]? [ at <position> ]? ] || <color-interpolation-method> ]? , <angular-color-stop-list>: an optional starting angle, an optional centre, and stops positioned by angle.

background: conic-gradient(#ffd21a 0 40%, #1f6fff 0 75%, #ddd 0);
border-radius: 50%;
A three-slice pie chart: hard stops at 40% and 75% of the turn.

Repeating gradients

repeating-linear-gradient()

A linear gradient whose colour stops repeat along the line. The distance from the first stop to the last becomes one tile, repeated in both directions to fill the box.

Syntaxrepeating-linear-gradient( [ <linear-gradient-syntax> ] )
Returns<image>
SupportChrome 26 · Firefox 16 · Safari 7
Speccss-images-4
background: repeating-linear-gradient(45deg, #ffd21a 0 10px, #222 10px 20px);
Diagonal hazard stripes, each band 10px wide.

repeating-radial-gradient()

A radial gradient whose colour stops repeat outwards, giving concentric rings.

Syntaxrepeating-radial-gradient( [ <radial-gradient-syntax> ] )
Returns<image>
SupportChrome 26 · Firefox 16 · Safari 7
Speccss-images-4

repeating-conic-gradient()

A conic gradient whose colour stops repeat around the turn, giving rays or a starburst.

Syntaxrepeating-conic-gradient( [ <conic-gradient-syntax> ] )
Returns<image>
SupportChrome 69 · Firefox 83 · Safari 12.1
Speccss-images-4
background: repeating-conic-gradient(#ccc 0 25%, #fff 0 50%) 0 0 / 20px 20px;
A checkerboard: two 90-degree wedges of each colour per 20px tile.