This page is Ready to Use

Notice: The WebPlatform project, supported by various stewards between 2012 and 2015, has been discontinued. This site is now available on github.

linear-gradient

Summary

Defines a linear gradient as a CSS image.

Examples

background: #1e5799;
background: -moz-linear-gradient(top, #1e5799 0%, #7db9e8 100%);
background: -webkit-gradient(linear, left top, left bottom, color-stop(0%,#1e5799), color-stop(100%,#7db9e8));
background: -webkit-linear-gradient(top, #1e5799 0%,#7db9e8 100%);
background: -o-linear-gradient(top, #1e5799 0%,#7db9e8 100%);
background: -ms-linear-gradient(top, #1e5799 0%,#7db9e8 100%);
background: linear-gradient(to bottom, #1e5799 0%,#7db9e8 100%);
filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#1e5799', endColorstr='#7db9e8',GradientType=0 );

View live example

Syntax

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

Parameters

angle
Optional. The angle the gradient line should assume, expressed as a number followed by an angle units designator(for instance, “deg”)."0deg" points upward and positive angles increase in a clockwise direction. Therefore, “90deg” points toward the right, “180deg” points downward, and so on.If no angle is provided, the gradient line starts in the corner or side opposite the corner or side specified by <side-or-corner>.
side-or-corner
Optional value that specifies an ending corner or side for the gradient. This value begins with "to", which is followed by one or two of the following keywords. Including one keyword specifies an ending side, and two keywords specify an ending corner.
  • The following values can be used as the first value only:
    • left Indicates gradient ends on the left.
    • right Indicates gradient ends on the right.
  • The following values can be used as the second value only:
    • top Indicates gradient ends on the top.
    • bottom Indicates gradient ends on the bottom.
  • Not including any keywords or angle is equivalent to "to bottom".
color-stop
At least two color stops are required. Each color stop has one or two components—a color component and an optional position component. The first component defines the color component of a stop point for the gradient. Each stop point has its own designated color, and the area between each point is filled with a continuous color transition from one to the other. This value can be any supported color value.Each stop point can have an optional percentage or supported length value that indicates where along the gradient line to place the color stop. “0%” (or "0px", "0em", and so on) indicates the starting point (or side); “100%” indicates the ending point (or side).

Related specifications

CSS Image Values and Replaced Content Module Level 3
Candidate Recommendation

See also

Related articles

Gradients

Attributions