<gradient>
Quick Summary for <gradient>
The <gradient> CSS data type is a special type of <image> that consists of a progressive transition between two or more colors.
Code Usage for <gradient>
More Details for <gradient>

<gradient>

The <gradient> CSS data type is a special type of <image> that consists of a progressive transition between two or more colors.

A CSS 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 to which it applies.

Syntax

The <gradient> data type is defined with one of the function types listed below.

Linear gradient

Linear gradients transition colors progressively along an imaginary line. They are generated with the linear-gradient() function.

Radial gradient

Radial gradients transition colors progressively from a center point (origin). They are generated with the radial-gradient() function.

Repeating gradient

Repeating gradients duplicate a gradient as much as necessary to fill a given area. They are generated with the repeating-linear-gradient() and repeating-radial-gradient() functions.

Conic gradient

Conic gradients transition colors progressively around a circle. They are generated with the conic-gradient() function.

Interpolation

As with any interpolation involving colors, gradients are calculated in the alpha-premultiplied color space. This prevents unexpected shades of gray from appearing when both the color and the opacity are changing. (Be aware that older browsers may not use this behavior when using the transparent keyword.)

Examples

Linear gradient example

A simple linear gradient.

.linear-gradient {   background: linear-gradient(to right,       red, orange, yellow, green, blue, indigo, violet); } 

Radial gradient example

A simple radial gradient.

.radial-gradient {   background: radial-gradient(red, yellow, rgb(30, 144, 255)); } 

Repeating gradient examples

Simple repeating linear and radial gradient examples.

.linear-repeat {   background: repeating-linear-gradient(to top left,       lightpink, lightpink 5px, white 5px, white 10px); }  .radial-repeat {   background: repeating-radial-gradient(powderblue, powderblue 8px, white 8px, white 16px); } 

Conic gradient example

A simple conic gradient example. Note that this isn't supported widely across browser as of yet.

.conic-gradient {   background: conic-gradient(lightpink, white, powderblue); } 

Specifications

Specification
CSS Image Values and Replaced Content Module Level 4 # gradients

See also

Using CSS gradients Gradient functions: linear-gradient(), repeating-linear-gradient(), radial-gradient(), repeating-radial-gradient(), conic-gradient(), repeating-conic-gradient() CSS Basic Data Types CSS Units and Values Introduction to CSS: Values and Units

Last modified: Aug 12, 2021, by MDN contributors

Select your preferred language English (US)DeutschEspañolFrançais日本語한국어中文 (简体) Change language

No Items Found.

Add Comment
Type in a Nick Name here
 
Other Categories in CSS
css
Search CSS
Search CSS by entering your search text above.
Welcome

This is my test area for webdev. I keep a collection of code here, mostly for my reference. Also if i find a good link, i usually add it here and then forget about it. more...

Subscribe to weekly updates about things i have added to the site or thought interesting during the last week.

You could also follow me on twitter or not... does anyone even use twitter anymore?

If you found something useful or like my work, you can buy me a coffee here. Mmm Coffee. ☕

❤️👩‍💻🎮

🪦 2000 - 16 Oct 2022 - Boots
Random Quote
The mind must be given relaxation; it will arise better and keener after resting. As rich fields must not be forced-for their productiveness, the have no rest, will quickly exhaust them constantlabor will break the vigor of the mind, but if it is released and relaxed a little while, it will recover its powers
Seneca
Random CSS Property

@font-feature-values

The @font-feature-values CSS at-rule lets you use a common name in the font-variant-alternates property for features activated differently in OpenType. This can help simplify your CSS when using multiple fonts.
@swash css reference