This is an experimental feature
Because this feature is still in development in some browsers, check the compatibility table for the proper prefixes to use in various browsers. Also note that the syntax and behavior of an experimental feature is subject to change in future version of browsers as the spec changes.

This works similarly to the standard linear gradients as described by linear-gradient , but it automatically repeats the color stops infinitely in both directions, with their positions shifted by multiples of the difference between the last color stop's position and the first one's position.

Like any other gradient, a repeating CSS linear gradient is not a CSS <color> but an image with no intrinsic dimensions; that is, it has no natural or preferred size, nor ratio. Its concrete size will match the one of the element it applies to.

Mozilla currently only supports CSS gradients as values of the background-image property, as well as within the shorthand background . You specify a gradient value instead of an image URL.


repeating-linear-gradient( [ [ <angle> | to <side-or-corner> ,]? <color-stop> [, <color-stop>]+ )

Vendor prefixes: See the compatibility table below for detail on the vendor prefixes you'll need to use for gradients.



<color> [ <percentage> | <length> ]


Represents the position of the starting-point of the gradient line. It consists of two keywords: the first one indicates the horizontal side, left or right, and the second one the vertical side, top or bottom. The order is not relevant and each of the keyword is optional.
The values to top, to bottom, to left and to right are translated into the angles 0deg, 180deg, 270deg, 90deg respectively. The others are translated into an angle that let the starting-point to be in the same quadrant than the described corner and so that the line defined by the starting-point and the corner is perpendicular to the gradient line. That way, the color described by the <color-stop> will exactly apply to the corner point. This is sometimes called the "magic corner" property. The end-point of the gradient line is the symmetrical point of the starting-point on the other direction of the center box.
An angle of direction for the gradient. See <angle> .
This value is comprised of a <color> value, followed by an optional stop position (either a percentage between 0% and 100% or a <length> along the gradient axis).
Rendering of color-stops in CSS gradients follows the same rules as color-stops in SVG gradients.


background: repeating-linear-gradient(to bottom right, red, red 5px, white 5px, white 10px);


Specification Status Comment
CSS Image Value and Replaced Content Module Level 3 Candidate Recommendation  

Browser compatibility

Feature Firefox (Gecko) Chrome Internet Explorer Opera Safari
Basic support 3.6 (1.9.2) -moz bug 479220 [3] 10.0 (534.16) -webkit [3] 10.0 -ms[1] 11.10 -o [3] 5.1 -webkit[3]
Legacy from syntax (without to) Non-standard 3.6 (1.9.2) -moz [2] 10.0 (534.16) -webkit 10.0 -ms [1] 11.10 -o 5.1 -webkit
to syntax

10.0 (10) -moz bug 685400 [2]

-- -- -- --

[1] Internet Explorer 5.5 through 8.0 supports proprietary filter: progid:DXImageTransform.Microsoft.Gradient() filter.

[2] Firefox 3.6 implemented, prefixed, an early syntax where the starting corner or side was indicated without the to keyword, and effectively considered as a from position. The to syntax has been added in Firefox 10, without removing the deprecated syntax and translation between the two is trivial:

-moz-repeating-linear-gradient(to top left, blue, red);

is the same as:

-moz-repeating-linear-gradient(bottom right, blue, red);

The legacy syntax, without to, is planned to go away when the prefix will be removed.


[3] Gecko, Opera & Webkit 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. This is different from the latest specification where an angle of 0deg as a direction indicator points to the top. [2] [3]

Tags (5)

Edit tags

Attachments (0)


Attach file