repeating-linear-gradient() CSS function

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.

* Some parts of this feature may have varying levels of support.

The repeating-linear-gradient() CSS function creates an image consisting of repeating linear gradients. It is similar to linear-gradient() and takes the same arguments, but it repeats the color stops infinitely in all directions so as to cover its entire container. The function's result is an object of the <gradient> data type, which is a special kind of <image>.

Try it

background: repeating-linear-gradient(
  #e66465,
  #e66465 20px,
  #9198e5 20px,
  #9198e5 25px
);
background: repeating-linear-gradient(45deg, #3f87a6, #ebf8e1 15%, #f69d3c 20%);
background:
  repeating-linear-gradient(transparent, #4d9f0c 40px),
  repeating-linear-gradient(0.25turn, transparent, #3f87a6 20px);
<section class="display-block" id="default-example">
  <div id="example-element"></div>
</section>
#example-element {
  min-height: 100%;
}

The length of the gradient that repeats is the distance between the first and last color stop. If the first color does not have a color-stop-length, the color-stop-length defaults to 0. With each repetition, the positions of the color stops are shifted by a multiple of the length of the basic linear gradient. Thus, the position of each ending color stop coincides with a starting color stop; if the color values are different, this will result in a sharp visual transition. This can be altered with repeating the first color again as the last color.

As with any gradient, a repeating linear 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 it applies to.

Because <gradient>s belong to the <image> data type, they can only be used where <image>s can be used. For this reason, repeating-linear-gradient() won't work on background-color and other properties that use the <color> data type.

Syntax

css
/* A repeating gradient tilted 45 degrees,
   starting blue and finishing red, repeating 3 times */
repeating-linear-gradient(45deg, blue, red 33.3%)

/* A repeating gradient going from the bottom right to the top left,
   starting blue and finishing red, repeating every 20px */
repeating-linear-gradient(to left top, blue, red 20px)

/* A gradient going from the bottom to top,
   starting blue, turning green after 40%,
   and finishing red. This gradient doesn't repeat because
   the last color stop defaults to 100% */
repeating-linear-gradient(0deg, blue, green 40%, red)

/* A gradient repeating five times, going from the left to right,
   starting red, turning green, and back to red */
repeating-linear-gradient(to right, red 0%, green 10%, red 20%)

/* Interpolation in rectangular color space */
repeating-linear-gradient(in oklab, blue, red 50px)

/* Interpolation in polar color space */
repeating-linear-gradient(in hsl, blue, red 50px)

/* Interpolation in polar color space
  with longer hue interpolation method */
repeating-linear-gradient(in hsl longer hue, blue, red 50px)

Values

<side-or-corner>

The position of the gradient line's starting point. If specified, it consists of the word to and up to two keywords: one indicates the horizontal side (left or right), and the other the vertical side (top or bottom). The order of the side keywords does not matter. If unspecified, it defaults to to bottom.

The values to top, to bottom, to left, and to right are equivalent to the angles 0deg, 180deg, 270deg, and 90deg respectively. The other values are translated into an angle.

<angle>

The gradient line's angle of direction. A value of 0deg is equivalent to to top; increasing values rotate clockwise from there.

<linear-color-stop>

A color-stop's <color> value, followed by one or two optional stop positions, (each being either a <percentage> or a <length> along the gradient's axis). A percentage of 0%, or a length of 0, represents the start of the gradient; the value 100% is 100% of the image size, meaning the gradient will not repeat.

<color-hint>

The color-hint is an interpolation hint defining how the gradient progresses between adjacent color stops. The length defines at which point between two color stops the gradient color should reach the midpoint of the color transition. If omitted, the midpoint of the color transition is the midpoint between two color stops.

Note: Rendering of color stops in repeating linear gradients follows the same rules as color stops in linear gradients.

Formal syntax

<repeating-linear-gradient()> = 
repeating-linear-gradient( [ <linear-gradient-syntax> ] )

<linear-gradient-syntax> =
[ [ <angle> | <zero> | to <side-or-corner> ] || <color-interpolation-method> ]? , <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> ]#?

<rectangular-color-space> =
srgb |
srgb-linear |
display-p3 |
display-p3-linear |
a98-rgb |
prophoto-rgb |
rec2020 |
lab |
oklab |
<xyz-space>

<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>

<xyz-space> =
xyz |
xyz-d50 |
xyz-d65

<color-stop-length> =
<length-percentage>{1,2}

<length-percentage> =
<length> |
<percentage>

Examples

Zebra stripes

css
body {
  background-image: repeating-linear-gradient(
    -45deg,
    transparent,
    transparent 20px,
    black 20px,
    black 40px
  );
  /* with multiple color stop lengths */
  background-image: repeating-linear-gradient(
    -45deg,
    transparent 0 20px,
    black 20px 40px
  );
}

Ten repeating horizontal bars

css
body {
  background-image: repeating-linear-gradient(
    to bottom,
    rgb(26 198 204),
    rgb(26 198 204) 7%,
    rgb(100 100 100) 10%
  );
}

Because the last color stop is 10% and the gradient is vertical, each gradient in the repeated gradient is 10% of the height, fitting 10 horizontal bars.

Interpolation in rectangular color space

css
body {
  background: repeating-linear-gradient(90deg in oklab, blue, red 100px);
}

Interpolating with hue

In this example for interpolation, hsl color system is being used and hue is being interpolated.

css
.shorter {
  background: repeating-linear-gradient(
    90deg in hsl shorter hue,
    red,
    blue 300px
  );
}

.longer {
  background: repeating-linear-gradient(
    90deg in hsl longer hue,
    red,
    blue 300px
  );
}

The box on the top uses shorter interpolation, meaning the color goes from red to blue using the shorter arc on the color wheel. The box on the bottom uses longer interpolation, meaning the color goes from red to blue using the longer arc, traversing through greens, yellows, and oranges.

Note: Please see Using CSS gradients for more examples.

Specifications

Specification
CSS Images Module Level 3
# repeating-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
repeating-linear-gradient()
Chrome – Full support
Chrome 10 (Release date: 2011-03-08)
prefix
prefix Implemented with the vendor prefix: -webkit-
Chrome – Full support
Chrome 26 (Release date: 2013-03-26)
footnote Full support
Edge – Full support
Edge 12 (Release date: 2015-07-29)
footnote Full support
Firefox – Full support
Firefox 3.6 (Release date: 2010-01-21)
prefix , footnote
prefix Implemented with the vendor prefix: -moz-
footnote Since Firefox 42, the prefixed version of gradients can be disabled by setting layout.css.prefixes.gradients to false.
footnote 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.
Firefox – Full support
Firefox 49 (Release date: 2016-09-20)
prefix
prefix Implemented with the vendor prefix: -webkit-
Firefox – Full support
Firefox 16 (Release date: 2012-10-09)
footnote
footnote Before Firefox 36, gradients weren't applied on the pre-multiplied color space, leading to shades of grey unexpectedly appearing when used with transparency.
Opera – No support
Opera 11 – 12.1 (Release date: 2010-12-16)
prefix
prefix Implemented with the vendor prefix: -o-
footnote 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.
Opera – Full support
Opera 15 (Release date: 2013-07-02)
prefix , footnote
prefix Implemented with the vendor prefix: -webkit-
footnote 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.
Opera – Full support
Opera 12.1 (Release date: 2012-11-20)
footnote Full support
Safari – Full support
Safari 5.1 (Release date: 2011-07-20)
prefix , footnote
prefix Implemented with the vendor prefix: -webkit-
footnote Safari 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.
footnote 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.
Safari – Full support
Safari 7 (Release date: 2013-10-22)
footnote Full support
Chrome Android – Full support
Chrome Android 18 (Release date: 2012-06-27)
prefix
prefix Implemented with the vendor prefix: -webkit-
Chrome Android – Full support
Chrome Android 26 (Release date: 2013-04-03)
footnote Full support
Firefox for Android – Full support
Firefox for Android 4 (Release date: 2011-03-29)
prefix , footnote
prefix Implemented with the vendor prefix: -moz-
footnote Since Firefox for Android 42, the prefixed version of gradients can be disabled by setting layout.css.prefixes.gradients to false.
footnote 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.
Firefox for Android – Full support
Firefox for Android 49 (Release date: 2016-09-20)
prefix
prefix Implemented with the vendor prefix: -webkit-
Firefox for Android – Full support
Firefox for Android 16 (Release date: 2012-10-09)
footnote
footnote Before 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.
Opera Android – No support
Opera Android 11 – 12.1 (Release date: 2011-03-22)
prefix
prefix Implemented with the vendor prefix: -o-
footnote 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.
Opera Android – Full support
Opera Android 14 (Release date: 2013-05-21)
prefix , footnote
prefix Implemented with the vendor prefix: -webkit-
footnote 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.
Opera Android – Full support
Opera Android 12.1 (Release date: 2012-10-09)
footnote Full support
Safari on iOS – Full support
Safari on iOS 5 (Release date: 2011-10-12)
prefix , footnote
prefix Implemented with the vendor prefix: -webkit-
footnote Safari 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.
footnote 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.
Safari on iOS – Full support
Safari on iOS 7 (Release date: 2013-09-18)
footnote Full support
Samsung Internet – Full support
Samsung Internet 1 (Release date: 2013-04-27)
prefix
prefix Implemented with the vendor prefix: -webkit-
Samsung Internet – Full support
Samsung Internet 1.5 (Release date: 2013-09-25)
footnote Full support
WebView Android – Full support
WebView Android 4.4 (Release date: 2013-12-09)
prefix
prefix Implemented with the vendor prefix: -webkit-
WebView Android – Full support
WebView Android 4.4 (Release date: 2013-12-09)
footnote Full support
WebView on iOS – Full support
WebView on iOS 5 (Release date: 2011-10-12)
prefix , footnote
prefix Implemented with the vendor prefix: -webkit-
footnote WebView 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.
footnote 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.
WebView on iOS – Full support
WebView on iOS 7 (Release date: 2013-09-18)
footnote Full support
Double-position color stops
Chrome – Full support
Chrome 71 (Release date: 2018-12-04)
footnote Full support
Edge – Full support
Edge 79 (Release date: 2020-01-15)
footnote Full support
Firefox – Full support
Firefox 64 (Release date: 2018-12-11)
footnote Full support
Opera – Full support
Opera 58 (Release date: 2019-01-23)
footnote Full support
Safari – Full support
Safari 12.1 (Release date: 2019-03-25)
footnote Full support
Chrome Android – Full support
Chrome Android 71 (Release date: 2018-12-04)
footnote Full support
Firefox for Android – Full support
Firefox for Android 64 (Release date: 2018-12-11)
footnote Full support
Opera Android – Full support
Opera Android 50 (Release date: 2019-02-18)
footnote Full support
Safari on iOS – Full support
Safari on iOS 12.2 (Release date: 2019-03-25)
footnote Full support
Samsung Internet – Full support
Samsung Internet 10 (Release date: 2019-08-22)
footnote Full support
WebView Android – Full support
WebView Android 71 (Release date: 2018-12-04)
footnote Full support
WebView on iOS – Full support
WebView on iOS 12.2 (Release date: 2019-03-25)
footnote Full support
Hue interpolation method
Chrome – Full support
Chrome 111 (Release date: 2023-03-07)
footnote Full support
Edge – Full support
Edge 111 (Release date: 2023-03-13)
footnote Full support
Firefox – Full support
Firefox 127 (Release date: 2024-06-11)
footnote Full support
Opera – Full support
Opera 97 (Release date: 2023-03-22)
footnote Full support
Safari – Full support
Safari 16.2 (Release date: 2022-12-13)
footnote Full support
Chrome Android – Full support
Chrome Android 111 (Release date: 2023-03-07)
footnote Full support
Firefox for Android – Full support
Firefox for Android 127 (Release date: 2024-06-11)
footnote Full support
Opera Android – Full support
Opera Android 75 (Release date: 2023-05-17)
footnote Full support
Safari on iOS – Full support
Safari on iOS 16.2 (Release date: 2022-12-13)
footnote Full support
Samsung Internet – Full support
Samsung Internet 22 (Release date: 2023-07-14)
footnote Full support
WebView Android – Full support
WebView Android 111 (Release date: 2023-03-01)
footnote Full support
WebView on iOS – Full support
WebView on iOS 16.2 (Release date: 2022-12-13)
footnote Full support
Interpolation color space
Chrome – Full support
Chrome 111 (Release date: 2023-03-07)
footnote Full support
Edge – Full support
Edge 111 (Release date: 2023-03-13)
footnote Full support
Firefox – Full support
Firefox 127 (Release date: 2024-06-11)
footnote Full support
Opera – Full support
Opera 97 (Release date: 2023-03-22)
footnote Full support
Safari – Full support
Safari 16.2 (Release date: 2022-12-13)
footnote Full support
Chrome Android – Full support
Chrome Android 111 (Release date: 2023-03-07)
footnote Full support
Firefox for Android – Full support
Firefox for Android 127 (Release date: 2024-06-11)
footnote Full support
Opera Android – Full support
Opera Android 75 (Release date: 2023-05-17)
footnote Full support
Safari on iOS – Full support
Safari on iOS 16.2 (Release date: 2022-12-13)
footnote Full support
Samsung Internet – Full support
Samsung Internet 22 (Release date: 2023-07-14)
footnote Full support
WebView Android – Full support
WebView Android 111 (Release date: 2023-03-01)
footnote Full support
WebView on iOS – Full support
WebView on iOS 16.2 (Release date: 2022-12-13)
footnote Full support
Interpolation Hints / Gradient Midpoints
Chrome – Full support
Chrome 40 (Release date: 2015-01-21)
footnote Full support
Edge – Full support
Edge 79 (Release date: 2020-01-15)
footnote Full support
Firefox – Full support
Firefox 36 (Release date: 2015-02-24)
footnote Full support
Opera – Full support
Opera 27 (Release date: 2015-01-27)
footnote Full support
Safari – Full support
Safari 7 (Release date: 2013-10-22)
footnote Full support
Chrome Android – Full support
Chrome Android 40 (Release date: 2015-01-21)
footnote Full support
Firefox for Android – Full support
Firefox for Android 36 (Release date: 2015-02-27)
footnote Full support
Opera Android – Full support
Opera Android 27 (Release date: 2015-01-29)
footnote Full support
Safari on iOS – Full support
Safari on iOS 7 (Release date: 2013-09-18)
footnote Full support
Samsung Internet – Full support
Samsung Internet 4 (Release date: 2016-03-11)
footnote Full support
WebView Android – Full support
WebView Android 40 (Release date: 2015-01-21)
footnote Full support
WebView on iOS – Full support
WebView on iOS 7 (Release date: 2013-09-18)
footnote Full support
Single color stop and 0-1 positions
Chrome – Full support
Chrome 135 (Release date: 2025-04-01)
footnote Full support
Edge – Full support
Edge 135 (Release date: 2025-04-04)
footnote Full support
Firefox – Full support
Firefox 136 (Release date: 2025-03-04)
footnote Full support
Opera – Full support
Opera 120 (Release date: 2025-07-02)
footnote Full support
Safari – Full support
Safari 18.4 (Release date: 2025-03-31)
footnote Full support
Chrome Android – Full support
Chrome Android 135 (Release date: 2025-04-01)
footnote Full support
Firefox for Android – Full support
Firefox for Android 136 (Release date: 2025-03-04)
footnote Full support
Opera Android – Full support
Opera Android 89 (Release date: 2025-04-29)
footnote Full support
Safari on iOS – Full support
Safari on iOS 18.4 (Release date: 2025-03-31)
footnote Full support
Samsung Internet – Full support
Samsung Internet 29 (Release date: 2025-10-25)
footnote Full support
WebView Android – Full support
WebView Android 135 (Release date: 2025-04-01)
footnote Full support
WebView on iOS – Full support
WebView on iOS 18.4 (Release date: 2025-03-31)
footnote Full support
to keyword
Chrome – Full support
Chrome 26 (Release date: 2013-03-26)
footnote Full support
Edge – Full support
Edge 12 (Release date: 2015-07-29)
footnote Full support
Firefox – Full support
Firefox 10 (Release date: 2012-01-31)
footnote Full support
Opera – Full support
Opera 12.1 (Release date: 2012-11-20)
footnote Full support
Safari – Full support
Safari 7 (Release date: 2013-10-22)
footnote Full support
Chrome Android – Full support
Chrome Android 26 (Release date: 2013-04-03)
footnote Full support
Firefox for Android – Full support
Firefox for Android 10 (Release date: 2012-01-31)
footnote Full support
Opera Android – Full support
Opera Android 14 (Release date: 2013-05-21)
footnote Full support
Safari on iOS – Full support
Safari on iOS 7 (Release date: 2013-09-18)
footnote Full support
Samsung Internet – Full support
Samsung Internet 1.5 (Release date: 2013-09-25)
footnote Full support
WebView Android – Full support
WebView Android 4.4 (Release date: 2013-12-09)
footnote Full support
WebView on iOS – Full support
WebView on iOS 7 (Release date: 2013-09-18)
footnote Full support
Unitless 0 for <angle>
Chrome – Full support
Chrome 26 (Release date: 2013-03-26)
footnote Full support
Edge – Full support
Edge 12 (Release date: 2015-07-29)
footnote Full support
Firefox – Partial support
Firefox 46 – 54 (Release date: 2016-04-26)
footnote Partial support
footnote Accepted only in -webkit-repeating-linear-gradient() and -moz-repeating-linear-gradient(), not repeating-linear-gradient().
Firefox – Full support
Firefox 55 (Release date: 2017-08-08)
footnote Full support
Opera – Full support
Opera 16 (Release date: 2013-08-27)
footnote Full support
Safari – Full support
Safari 7 (Release date: 2013-10-22)
footnote Full support
Chrome Android – Full support
Chrome Android 26 (Release date: 2013-04-03)
footnote Full support
Firefox for Android – Partial support
Firefox for Android 46 – 54 (Release date: 2016-04-26)
footnote Partial support
footnote Accepted only in -webkit-repeating-linear-gradient() and -moz-repeating-linear-gradient(), not repeating-linear-gradient().
Firefox for Android – Full support
Firefox for Android 55 (Release date: 2017-08-08)
footnote Full support
Opera Android – Full support
Opera Android 14 (Release date: 2013-05-21)
footnote Full support
Safari on iOS – Full support
Safari on iOS 7 (Release date: 2013-09-18)
footnote Full support
Samsung Internet – Full support
Samsung Internet 1.5 (Release date: 2013-09-25)
footnote Full support
WebView Android – Full support
WebView Android 4.4 (Release date: 2013-12-09)
footnote Full support
WebView on iOS – Full support
WebView on iOS 7 (Release date: 2013-09-18)
footnote Full support

Legend

Tip: you can click/tap on a cell for more information.

Full support
Full support
Partial support
Partial support
See implementation notes.
Requires a vendor prefix or different name for use.
Has more compatibility info.

See also