Gradients are images that transition smoothly from one color to another. Internet Explorer 10 supports linear, circular, and elliptical CSS3 gradients, each of which are specified by a gradient line and two or more stop points. Each stop point has its own color, and Windows Internet Explorer fills in the area between each set of points with a continuous color transition from one to the other.

Linear gradients

In a linear gradient, colors transition smoothly along a line. Linear gradients are created by first specifying a gradient line for the gradient to follow, and then the two or more color stop points, separated by commas. The basic linear gradient syntax is as follows:

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

The following linear gradient (used as the argument for the background-image property) has three color stops:

The first color stop is in the top-right corner and defines a gradient line that extends to the bottom-left corner. The first stop is a shade of yellow.

The second color stop is halfway along the gradient line and is a shade of green.

The final color stop is 80% of the way along the gradient line and is a shade of blue. From this stop to the end of the gradient line (between 80% and 100%), the color remains this shade of blue.

The gradient line starts in the top-right corner of the rectangle and ends in the bottom-left corner. The actual angle depends on the dimensions of the element that the gradient fills.

Of course, if the size of the fill area changes, these two gradients look different. Keep this in mind when deciding how to specify your gradients. The first defined gradient (with "to bottom left" specified) is pictured here in a 450px-by-150px box.

The second defined gradient (with "210deg" specified) is pictured here in the same size box.

Radial gradients

In contrast to linear gradients, which progress from one end of a line to the other, radial gradients emerge from a single point, and then smoothly spread outward in a circle or ellipse. You specify a radial gradient by first defining a center point, then the size and shape (if an ellipse) of the final—or 100%—circle or ellipse, and then the color stops in between, and is separated by commas. The basic radial gradient syntax is as follows:

Specifies a radial gradient by first defining a center point, then the size and shape (if an ellipse) of the final—or 100%—circle or ellipse, and then the color stops in between, separated by commas.

The possible values for the property are as follows:

<shape>

Optional value that specifies the ending shape of the gradient. If this value is omitted, the ending shape is a circle if the size parameter is a single length value, and an ellipse otherwise.

ellipse Indicates gradient is in the shape of an ellipse.

circle Indicates gradient is in the shape of an circle.

<size>

Optional value that specifies the size of the gradient's ending shape. If this value is omitted, it defaults to farthest-corner.

<length(s)>

One or two space-delimited length values or two percentages.

If one length value is specified, it indicates the radius of the circle.

If two values (length or percent) are specified, the first value represents the horizontal radius, and the second the vertical radius.

Percentage values are relative to the corresponding dimension of the gradient box. Percentages can only be used to specify the size of an elliptical gradient, not a circular one.

Negative values are invalid.

closest-side For circular gradients, this value indicates that the ending-shape is circle sized so that it exactly meets the side of the box closest to its center. For elliptical gradients, the gradient-shape is an ellipse size so that it exactly meets the vertical and horizontal sides of the box closest to its center.

closest-corner Sizes the gradient-shape so that it exactly meets the closest corner of the box from its center. For elliptical gradients, the gradient-shape has the same ratio of width to height that it would if closest-side was specified.

farthest-side Similar to closest-side, except the gradient-shape is sized to meet the side of the box that is farthest from its center (for circular gradients) or the farthest vertical and horizontal sides (for elliptical gradients).

farthest-corner Sizes the gradient-shape so that it exactly meets the farthest corner of the box from its center. For elliptical gradients, the gradient-shape has the same ratio of width to height that it would if farthest-side was specified.

<position>

Optional value that specifies the center of the gradient. This value can take the same values as the background-position property. If this value is omitted, it defaults to center.

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

The second component is an optional percentage or decimal value that indicates where along the gradient ray (similar to a gradient line in a linear-gradient, but from the center outward) to place the color stop. "0%" indicates the start of the gradient ray, and "100%" indicates the point where the gradient ray intersects the ending shape. For instance, a value of "20%" indicates the color stop should be placed at a point 20% of the length of the gradient ray, starting from the beginning of the line. Values can be negative, which indicates that the specified color for that value is at mid-transition to the next color at the center of the gradient, so the visible color at the center will be somewhere between the specified color and the next color. Values can be greater than 100%, which specifies a location a correspondingly greater distance from the center of the gradient.

Often different radial gradient syntax can be used to produce the same results. For instance, all three of the following examples, when applied to a 250×150-pixel div element, produce the image shown here.

Of course, you can also originate the radial gradient in locations other than the center of the gradient box. Use the closest-side or farthest-side keywords to size the gradient so that the ending shape meets either the closest or farthest side, respectively, of the gradient box.

The following examples set the center of the gradient at 40px from the left side of the gradient box and 50px from the top side of the gradient box. The first example uses closest-side, so the ending shape of the gradient is defined by the closest sides of the gradient box—namely, the top and left sides.

Repeating gradients

Internet Explorer 10 and Windows Store apps using JavaScript also support repeating linear and radial gradients. The syntax of each of the repeating gradient properties is identical to its non-repeating sibling.

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

After the last color stop has been reached, the gradient starts again at the first color stop and repeats. It's a good idea to specify identical colors for the first and last color stops to prevent abrupt color changes between each repeating group.

Following is an example of a repeating linear gradient. It transitions between two colors—blue and yellow.

Specifies a repeating radial gradient by first defining a center point, then the size and shape (if an ellipse) of the final—or 100%—circle or ellipse, and then the color stops in between, separated by commas.

The possible values for the property are as follows:

<shape>

Optional value that specifies the ending shape of the gradient. If this value is omitted, the ending shape is a circle if the size parameter is a single length value, and an ellipse otherwise.

ellipse Indicates gradient is in the shape of an ellipse.

circle Indicates gradient is in the shape of a circle.

<size>

Optional value that specifies the size of the gradient's ending shape. Its possible values are either two space-delimited length values (or percentages) or one of the following keywords. If this value is omitted, it defaults to farthest-corner.

<length(s)>

One or two space-delimited length values or two percentages.

If one length value is specified, it indicates the radius of the circle.

If two values (length or percent) are specified, the first value represents the horizontal radius, and the second the vertical radius.

Percentage values are relative to the corresponding dimension of the gradient box. Percentages can only be used to specify the size of an elliptical gradient, not a circular one.

Negative values are invalid.

closest-side For circular gradients, this value indicates that the ending-shape is circle sized so that it exactly meets the side of the box closest to its center. For elliptical gradients, the gradient-shape is an ellipse size so that it exactly meets the vertical and horizontal sides of the box closest to its center.

closest-corner Sizes the gradient-shape so that it exactly meets the closest corner of the box from its center. For elliptical gradients, the gradient-shape has the same ratio of width to height that it would if closest-side was specified.

farthest-side Similar to closest-side, except the gradient-shape is sized to meet the side of the box that is farthest from its center (for circular gradients) or the farthest vertical and horizontal sides (for elliptical gradients).

farthest-corner Sizes the gradient-shape so that it exactly meets the farthest corner of the box from its center. For elliptical gradients, the gradient-shape has the same ratio of width to height that it would if farthest-side was specified.

<position>

Optional value that specifies the center of the gradient. This value can take the same values as the background-position property. If this value is omitted, it defaults to center.

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

The second component is an optional percentage or decimal value that indicates where along the gradient ray (similar to a gradient line in a linear-gradient, but from the center outward) to place the color stop. "0%" indicates the start of the gradient ray, and "100%" indicates the point where the gradient ray intersects the ending shape. For instance, a value of "20%" indicates the color stop should be placed at a point 20% of the length of the gradient ray, starting from the beginning of the line. Values can be negative, which indicates that the specified color for that value is at mid-transition to the next color at the center of the gradient, so the visible color at the center will be somewhere between the specified color and the next color. Values can be greater than 100%, which specifies a location a correspondingly greater distance from the center of the gradient.

After the last color stop has been reached, the gradient starts again at the first color stop and repeats. It's a good idea to specify identical colors for the first and last color stops to prevent abrupt color changes between each repeating group.

Gradient Midpoints

Microsoft Edge introduced support for CSS Gradient Midpoints, or color hints. With CSS Gradient Midpoints, you can specify an optional location between the color stops of a CSS gradient. The color will always be exactly between the colors of the two stops at that point. Other colors along the gradient line are calculated using an exponential interpolation function described by the CSS Image Values and Replaced Content Module Level 3 specification.

In the following example a of a 90 degree, green and yellow linear gradient, a midpoint is placed at 30%.