gradient property

Image Tutorials

Definition and Usage

The <gradient> CSS data type denotes a CSS <image> made of a progressive transition between two or more colors. A CSS 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.

There are several types of colors gradients:

  • linear gradients, generated by the linear-gradient() function, where the color smoothly fades along an imaginary line.
    A rainbow made from a gradient
    1 background-image: linear-gradient(to rightred, orange, yellow, greenblue, indigo, violet);
  • radial gradients, generated by the radial-gradient() function. The more away from an origin a point is, the more far from the original color it is.
    Radial gradient
    1 background: radial-gradient(red, yellow, rgb(30144255));
  • repeating gradients, which are fixed sized linear or radial gradients repeated as much as needed to fill the entire box.
    Repeating gradient
    1 background: repeating-linear-gradient(top left -45deg, redred 5pxwhite 5pxwhite 10px);

Like with any case involving interpolation of colors, gradients are calculated in the alpha-premultiplied color space. This prevents unexpected shades of grey to appear when both the color and the opacity are varying.

Examples

No examples


Compatibility

Each different gradient type has a different compatibility matrix. Please consult each individual article.

Rate article