`<gradient>` CSS type
Baseline Widely available
This feature is well established and works across many devices and browser versions. It's been available across browsers since July 2015.
The <gradient> CSS data type is a special type of <image> that consists of a progressive transition between two or more colors.
A CSS gradient has no intrinsic dimensions; i.e., it has no natural or preferred size, nor a preferred ratio. Its concrete size will match the size of the element to which it applies.
Try it
background: linear-gradient(#f69d3c, #3f87a6);
background: radial-gradient(#f69d3c, #3f87a6);
background: repeating-linear-gradient(#f69d3c, #3f87a6 50px);
background: repeating-radial-gradient(#f69d3c, #3f87a6 50px);
background: conic-gradient(#f69d3c, #3f87a6);
<section class="display-block" id="default-example"> <div id="example-element"></div> </section>
#example-element {
min-height: 100%;
}
Syntax
The <gradient> data type is defined with one of the function types listed below.
Linear gradient
Linear gradients transition colors progressively along an imaginary line. They are generated with the linear-gradient() function.
Radial gradient
Radial gradients transition colors progressively from a center point (origin). They are generated with the radial-gradient() function.
Conic gradient
Conic gradients transition colors progressively around a circle. They are generated with the conic-gradient() function.
Repeating gradient
Repeating gradients duplicate a gradient as much as necessary to fill a given area. They are generated with the repeating-linear-gradient(), repeating-radial-gradient(), and repeating-conic-gradient() functions.
Interpolation
As with any interpolation involving colors, gradients are calculated in the alpha-premultiplied color space. This prevents unexpected shades of gray from appearing when both the color and the opacity are changing. (Be aware that older browsers may not use this behavior when using the transparent keyword.)
Formal syntax
<gradient> = <linear-gradient()> | <repeating-linear-gradient()> | <radial-gradient()> | <repeating-radial-gradient()> | <conic-gradient()> | <repeating-conic-gradient()> <linear-gradient()> = linear-gradient( [ <linear-gradient-syntax> ] ) <repeating-linear-gradient()> = repeating-linear-gradient( [ <linear-gradient-syntax> ] ) <radial-gradient()> = radial-gradient( [ <radial-gradient-syntax> ] ) <repeating-radial-gradient()> = repeating-radial-gradient( [ <radial-gradient-syntax> ] ) <conic-gradient()> = conic-gradient( [ <conic-gradient-syntax> ] ) <repeating-conic-gradient()> = repeating-conic-gradient( [ <conic-gradient-syntax> ] ) <linear-gradient-syntax> = [ [ <angle> | <zero> | to <side-or-corner> ] || <color-interpolation-method> ]? , <color-stop-list> <radial-gradient-syntax> = [ [ [ <radial-shape> || <radial-size> ]? [ at <position> ]? ] || <color-interpolation-method> ]? , <color-stop-list> <conic-gradient-syntax> = [ [ [ from [ <angle> | <zero> ] ]? [ at <position> ]? ] || <color-interpolation-method> ]? , <angular-color-stop-list> <side-or-corner> = [ left | right ] || [ top | bottom ] <color-interpolation-method> = in [ <rectangular-color-space> | <polar-color-space> <hue-interpolation-method>? | <custom-color-space> ] <color-stop-list> = <linear-color-stop> , [ <linear-color-hint>? , <linear-color-stop> ]#? <radial-shape> = circle | ellipse <radial-size> = <radial-extent> | <length [0,∞]> | <length-percentage [0,∞]>{2} <position> = [ [ left | center | right ] || [ top | center | bottom ] | [ left | center | right | <length-percentage> ] [ top | center | bottom | <length-percentage> ]? | [ [ left | right ] <length-percentage> ] && [ [ top | bottom ] <length-percentage> ] ] <angular-color-stop-list> = <angular-color-stop> , [ <angular-color-hint>? , <angular-color-stop> ]#? <rectangular-color-space> = srgb | srgb-linear | display-p3 | display-p3-linear | a98-rgb | prophoto-rgb | rec2020 | lab | oklab | xyz | xyz-d50 | xyz-d65 <polar-color-space> = hsl | hwb | lch | oklch <hue-interpolation-method> = [ shorter | longer | increasing | decreasing ] hue <custom-color-space> = <dashed-ident> <linear-color-stop> = <color> <color-stop-length>? <linear-color-hint> = <length-percentage> <radial-extent> = closest-corner | closest-side | farthest-corner | farthest-side <length-percentage> = <length> | <percentage> <angular-color-stop> = <color> <color-stop-angle>? <angular-color-hint> = <angle-percentage> | <zero> <color> = <color-base> | currentColor | <system-color> | <light-dark()> | <deprecated-system-color> <color-stop-length> = <length-percentage>{1,2} <color-stop-angle> = [ <angle-percentage> | <zero> ]{1,2} <angle-percentage> = <angle> | <percentage> <color-base> = <hex-color> | <color-function> | <named-color> | <color-mix()> | transparent <system-color> = AccentColor | AccentColorText | ActiveText | ButtonBorder | ButtonFace | ButtonText | Canvas | CanvasText | Field | FieldText | GrayText | Highlight | HighlightText | LinkText | Mark | MarkText | SelectedItem | SelectedItemText | VisitedText <light-dark()> = light-dark( <color>, <color> ) <deprecated-system-color> = ActiveBorder | ActiveCaption | AppWorkspace | Background | ButtonHighlight | ButtonShadow | CaptionText | InactiveBorder | InactiveCaption | InactiveCaptionText | InfoBackground | InfoText | Menu | MenuText | Scrollbar | ThreeDDarkShadow | ThreeDFace | ThreeDHighlight | ThreeDLightShadow | ThreeDShadow | Window | WindowFrame | WindowText <color-function> = <rgb()> | <rgba()> | <hsl()> | <hsla()> | <hwb()> | <lab()> | <lch()> | <oklab()> | <oklch()> | <color()> <named-color> = aliceblue | antiquewhite | aqua | aquamarine | azure | beige | bisque | black | blanchedalmond | blue | blueviolet | brown | burlywood | cadetblue | chartreuse | chocolate | coral | cornflowerblue | cornsilk | crimson | cyan | darkblue | darkcyan | darkgoldenrod | darkgray | darkgreen | darkgrey | darkkhaki | darkmagenta | darkolivegreen | darkorange | darkorchid | darkred | darksalmon | darkseagreen | darkslateblue | darkslategray | darkslategrey | darkturquoise | darkviolet | deeppink | deepskyblue | dimgray | dimgrey | dodgerblue | firebrick | floralwhite | forestgreen | fuchsia | gainsboro | ghostwhite | gold | goldenrod | gray | green | greenyellow | grey | honeydew | hotpink | indianred | indigo | ivory | khaki | lavender | lavenderblush | lawngreen | lemonchiffon | lightblue | lightcoral | lightcyan | lightgoldenrodyellow | lightgray | lightgreen | lightgrey | lightpink | lightsalmon | lightseagreen | lightskyblue | lightslategray | lightslategrey | lightsteelblue | lightyellow | lime | limegreen | linen | magenta | maroon | mediumaquamarine | mediumblue | mediumorchid | mediumpurple | mediumseagreen | mediumslateblue | mediumspringgreen | mediumturquoise | mediumvioletred | midnightblue | mintcream | mistyrose | moccasin | navajowhite | navy | oldlace | olive | olivedrab | orange | orangered | orchid | palegoldenrod | palegreen | paleturquoise | palevioletred | papayawhip | peachpuff | peru | pink | plum | powderblue | purple | rebeccapurple | red | rosybrown | royalblue | saddlebrown | salmon | sandybrown | seagreen | seashell | sienna | silver | skyblue | slateblue | slategray | slategrey | snow | springgreen | steelblue | tan | teal | thistle | tomato | turquoise | violet | wheat | white | whitesmoke | yellow | yellowgreen <color-mix()> = color-mix( <color-interpolation-method> , [ <color> && <percentage [0,100]>? ]#{2}) <rgb()> = rgb( <percentage>#{3} , <alpha-value>? ) | rgb( <number>#{3} , <alpha-value>? ) | rgb( [ <number> | <percentage> | none ]{3} [ / [ <alpha-value> | none ] ]? ) <rgba()> = rgba( <percentage>#{3} , <alpha-value>? ) | rgba( <number>#{3} , <alpha-value>? ) | rgba( [ <number> | <percentage> | none ]{3} [ / [ <alpha-value> | none ] ]? ) <hsl()> = hsl( <hue>, <percentage>, <percentage>, <alpha-value>? ) | hsl( [ <hue> | none ] [ <percentage> | <number> | none ] [ <percentage> | <number> | none ] [ / [ <alpha-value> | none ] ]? ) <hsla()> = hsla( <hue>, <percentage>, <percentage>, <alpha-value>? ) | hsla( [ <hue> | none ] [ <percentage> | <number> | none ] [ <percentage> | <number> | none ] [ / [ <alpha-value> | none ] ]? ) <hwb()> = hwb( [ <hue> | none ] [ <percentage> | <number> | none ] [ <percentage> | <number> | none ] [ / [ <alpha-value> | none ] ]? ) <lab()> = lab( [<percentage> | <number> | none] [ <percentage> | <number> | none] [ <percentage> | <number> | none] [ / [<alpha-value> | none] ]? ) <lch()> = lch( [<percentage> | <number> | none] [ <percentage> | <number> | none] [ <hue> | none] [ / [<alpha-value> | none] ]? ) <oklab()> = oklab( [ <percentage> | <number> | none] [ <percentage> | <number> | none] [ <percentage> | <number> | none] [ / [<alpha-value> | none] ]? ) <oklch()> = oklch( [ <percentage> | <number> | none] [ <percentage> | <number> | none] [ <hue> | none] [ / [<alpha-value> | none] ]? ) <color()> = color( [ from <color> ]? <colorspace-params> [ / [ <alpha-value> | none ] ]? ) <alpha-value> = <number> | <percentage> <hue> = <number> | <angle> <colorspace-params> = [<custom-params> | <predefined-rgb-params> | <xyz-params>] <custom-params> = <dashed-ident> [ <number> | <percentage> | none ]+ <predefined-rgb-params> = <predefined-rgb> [ <number> | <percentage> | none ]{3} <xyz-params> = <xyz> [ <number> | <percentage> | none ]{3}
Examples
Linear gradient example
A linear gradient.
<div class="linear-gradient">Linear gradient</div>
div {
width: 240px;
height: 80px;
}
.linear-gradient {
background: linear-gradient(
to right,
red,
orange,
yellow,
green,
blue,
indigo,
violet
);
}
Radial gradient example
A radial gradient.
<div class="radial-gradient">Radial gradient</div>
div {
width: 240px;
height: 80px;
}
.radial-gradient {
background: radial-gradient(red, yellow, dodgerblue);
}
Conic gradient example
A conic gradient example.
<div class="conic-gradient">Conic gradient</div>
div {
width: 200px;
height: 200px;
}
.conic-gradient {
background: conic-gradient(pink, coral, lime);
}
Repeating gradient examples
Repeating linear and radial gradient examples.
<div class="linear-repeat"></div> <span>Repeating linear gradient</span> <hr /> <div class="radial-repeat"></div> <span>Repeating radial gradient</span> <hr /> <div class="conic-repeat"></div> <span>Repeating conic gradient</span>
div {
display: inline-block;
width: 240px;
height: 80px;
}
span {
font-weight: bold;
vertical-align: top;
}
.linear-repeat {
background: repeating-linear-gradient(
to top left,
pink,
pink 5px,
white 5px,
white 10px
);
}
.radial-repeat {
background: repeating-radial-gradient(
lime,
lime 15px,
white 15px,
white 30px
);
}
.conic-repeat {
background: repeating-conic-gradient(lime, pink 30deg);
}
Specifications
| Specification |
|---|
| CSS Images Module Level 4 # gradients |
Browser compatibility
| Desktop | Mobile | |||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|
| Chrome | Edge | Firefox | Opera | Safari | Chrome Android | Firefox for Android | Opera Android | Safari on iOS | Samsung Internet | WebView Android | WebView on iOS | |
gradient |
26
10
|
12 |
3.6 |
12.1
15
11–15
|
7
5.1
|
26
18
|
4 |
12.1
14
11–14
|
7
5
|
1.5
1.0
|
4.4
4.4
|
7
5
|
conic-gradient |
69 |
79 |
83 |
56 |
12.1 |
69 |
83 |
48 |
12.2 |
10.0 |
69 |
12.2 |
linear-gradient |
26
10
|
12 |
16
49
3.6Since Firefox 42, the prefixed version of gradients can be disabled by settinglayout.css.prefixes.gradients to false.Considers <angle> to start to the right, instead of the top. I.e. it considered an angle of 0deg as a direction indicator pointing to the right. |
12.1
15Considers<angle> to start to the right, instead of the top. I.e. it considered an angle of 0deg as a direction indicator pointing to the right.11–15Considers<angle> to start to the right, instead of the top. I.e. it considered an angle of 0deg as a direction indicator pointing to the right. |
7
5.1Safari 4 was supporting an experimental-webkit-gradient(linear,…) function. It is more limited than the later standard version: you cannot specify both a position and an angle like in linear-gradient(). This old outdated syntax is still supported for compatibility purposes.Considers <angle> to start to the right, instead of the top. I.e. it considered an angle of 0deg as a direction indicator pointing to the right. |
26
18
|
16
49
4Since Firefox for Android 42, the prefixed version of gradients can be disabled by settinglayout.css.prefixes.gradients to false.Considers <angle> to start to the right, instead of the top. I.e. it considered an angle of 0deg as a direction indicator pointing to the right. |
12.1
14Considers<angle> to start to the right, instead of the top. I.e. it considered an angle of 0deg as a direction indicator pointing to the right.11–14Considers<angle> to start to the right, instead of the top. I.e. it considered an angle of 0deg as a direction indicator pointing to the right. |
7
5Safari on iOS 3.2 was supporting an experimental-webkit-gradient(linear,…) function. It is more limited than the later standard version: you cannot specify both a position and an angle like in linear-gradient(). This old outdated syntax is still supported for compatibility purposes.Considers <angle> to start to the right, instead of the top. I.e. it considered an angle of 0deg as a direction indicator pointing to the right. |
1.5
1.0
|
4.4
4.4
|
7
5WebView on iOS 3.2 was supporting an experimental-webkit-gradient(linear,…) function. It is more limited than the later standard version: you cannot specify both a position and an angle like in linear-gradient(). This old outdated syntax is still supported for compatibility purposes.Considers <angle> to start to the right, instead of the top. I.e. it considered an angle of 0deg as a direction indicator pointing to the right. |
radial-gradient |
26
13
|
12 |
16
49
3.6Since Firefox 42, the prefixed version of gradients can be disabled by settinglayout.css.prefixes.gradients to false. |
12.1
15
11.6–15
|
7
5.1Safari 4 was supporting an experimental-webkit-gradient(radial,…) function. This old outdated syntax is still supported for compatibility purposes. |
26
18
|
16
49
4Since Firefox for Android 42, the prefixed version of gradients can be disabled by settinglayout.css.prefixes.gradients to false. |
12.1
14
12–14
|
7
5Safari on iOS 3.2 was supporting an experimental-webkit-gradient(radial,…) function. This old outdated syntax is still supported for compatibility purposes. |
1.5
1.0
|
4.4
4.4
|
7
5WebView on iOS 3.2 was supporting an experimental-webkit-gradient(radial,…) function. This old outdated syntax is still supported for compatibility purposes. |
repeating-conic-gradient |
69 |
79 |
83 |
56 |
12.1 |
69 |
83 |
48 |
12.2 |
10.0 |
69 |
12.2 |
repeating-linear-gradient |
26
10
|
12 |
16Before Firefox 36, gradients weren't applied on the pre-multiplied color space, leading to shades of grey unexpectedly appearing when used with transparency.49
3.6Since Firefox 42, the prefixed version of gradients can be disabled by settinglayout.css.prefixes.gradients to false.Considers <angle> to start to the right, instead of the top. I.e. it considered an angle of 0deg as a direction indicator pointing to the right. |
12.1
15Considers<angle> to start to the right, instead of the top. I.e. it considered an angle of 0deg as a direction indicator pointing to the right.11–15Considers<angle> to start to the right, instead of the top. I.e. it considered an angle of 0deg as a direction indicator pointing to the right. |
7
5.1Safari 4 was supporting an experimental-webkit-gradient(linear,…) function. It is more limited than the later standard version: you cannot specify both a position and an angle like in repeating-linear-gradient(). This old outdated syntax is still supported for compatibility purposes.Considers <angle> to start to the right, instead of the top. I.e. it considered an angle of 0deg as a direction indicator pointing to the right. |
26
18
|
16Before Firefox for Android 36, gradients weren't applied on the pre-multiplied color space, leading to shades of grey unexpectedly appearing when used with transparency.49
4Since Firefox for Android 42, the prefixed version of gradients can be disabled by settinglayout.css.prefixes.gradients to false.Considers <angle> to start to the right, instead of the top. I.e. it considered an angle of 0deg as a direction indicator pointing to the right. |
12.1
14Considers<angle> to start to the right, instead of the top. I.e. it considered an angle of 0deg as a direction indicator pointing to the right.11–14Considers<angle> to start to the right, instead of the top. I.e. it considered an angle of 0deg as a direction indicator pointing to the right. |
7
5Safari on iOS 3.2 was supporting an experimental-webkit-gradient(linear,…) function. It is more limited than the later standard version: you cannot specify both a position and an angle like in repeating-linear-gradient(). This old outdated syntax is still supported for compatibility purposes.Considers <angle> to start to the right, instead of the top. I.e. it considered an angle of 0deg as a direction indicator pointing to the right. |
1.5
1.0
|
4.4
4.4
|
7
5WebView on iOS 3.2 was supporting an experimental-webkit-gradient(linear,…) function. It is more limited than the later standard version: you cannot specify both a position and an angle like in repeating-linear-gradient(). This old outdated syntax is still supported for compatibility purposes.Considers <angle> to start to the right, instead of the top. I.e. it considered an angle of 0deg as a direction indicator pointing to the right. |
repeating-radial-gradient |
26
10
|
12 |
16Before Firefox 36, gradients weren't applied on the pre-multiplied color space, leading to shades of grey unexpectedly appearing when used with transparency.49
3.6Since Firefox 42, the prefixed version of gradients can be disabled by settinglayout.css.prefixes.gradients to false. |
12.1
15
12–15
|
7
5.1Safari 4 was supporting an experimental-webkit-gradient(radial,…) function. This old outdated syntax is still supported for compatibility purposes. |
26
18
|
16Before Firefox 36, gradients weren't applied on the pre-multiplied color space, leading to shades of grey unexpectedly appearing when used with transparency.49
10Since Firefox 42, the prefixed version of gradients can be disabled by settinglayout.css.prefixes.gradients to false. |
12.1
14
12–14
|
7
5Safari on iOS 3.2 was supporting an experimental-webkit-gradient(radial,…) function. This old outdated syntax is still supported for compatibility purposes. |
1.5
1.0
|
4.4
4.4
|
7
5WebView on iOS 3.2 was supporting an experimental-webkit-gradient(radial,…) function. This old outdated syntax is still supported for compatibility purposes. |
See also
- Using CSS gradients
- Gradient functions:
linear-gradient(),repeating-linear-gradient(),radial-gradient(),repeating-radial-gradient(),conic-gradient(),repeating-conic-gradient() - CSS Basic Data Types
- CSS values and units module
- Learn: Values and Units
© 2005–2025 MDN contributors.
Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.
https://developer.mozilla.org/en-US/docs/Web/CSS/Reference/Values/gradient