We're looking for a user researcher to understand the needs of developers and designers. Is this you or someone you know? Check out the post: https://mzl.la/2IGzdXS

radial-gradient Redirect 1


The CSS radial-gradient() function creates an <image> which represents a gradient of colors radiating from an origin, the center of the gradient. The result of this function is an object of the CSS <gradient> data type.

Radial gradients are defined by their center, the ending shape contour and position, and color stops. The radial gradient consists, going from its center to its ending shape and potentially beyond, of successive uniformly-scaled concentric shapes, identical to the ending shape. Color stops are positioned on a virtual gradient ray going out horizontally of the center and going to the right. Percentages positioning of color stops are relative to the intersection between the ending shape and this gradient ray representing 100%. Each shape is monocolor and defined by the color on the gradient ray it intersects.

Ending shapes can only be circle or ellipse.

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

The radial-gradient function does not allow repeating gradients. For such a functionality, use the CSS repeating-radial-gradient function.


Formal grammar: 
  radial-gradient( [[ circle               || <length> ]                     [ at <position> ]? , | 
                    [ ellipse              || [<length> | <percentage> ]{2}] [ at <position> ]? , |
                    [ [ circle | ellipse ] || <extent-keyword> ]             [ at <position> ]? , |
                                                                               at <position> ,     <color-stop> [ , <color-stop> ]+ )
                                 Definition of the contour, size and position of the ending shape         List of color stops  
          where <extent-keyword> = closest-corner | closest-side | farthest-corner | farthest-side
            and <color-stop> = <color> [ <percentage> | <length> ]?
Definition of the ending shape
radial-gradient( circle, … )                /* Synonym of radial-gradient( circle farthest-corner, …) */
radial-gradient( ellipse, … )               /* Synonym of radial-gradient( ellipse farthest-corner, …) */
radial-gradient( <extent-keyword>, … )      /* It draws a circle */
radial-gradient( circle radius, … )         /* A centered circle of the given length. It can't be a percentage */
radial-gradient( ellipse x-axis y-axis, … ) /* The two semi-major axis are given, horizontal, then vertical */

Definition of the position of the shape
radial-gradient (… at <position>, … )

Definition of the color stops
radial-gradient (…, <color-stop>)
radial-gradient (…, <color-stop>, <color-stop>)


A <position>, interpreted in the same way as background-position or transform-origin. If omitted, the default is center.
The gradient's shape. This is one of circle (meaning that the gradient's shape is a circle with constant radius) or ellipse (meaning that the shape is an axis-aligned ellipse). The default value is ellipse.
The size of the gradient. This is one of the Size constants listed below.
Representing a fixed color at a precise position, this value is composed by a <color> value, followed by an optional stop position (either a <percentage> or a <length> along the virtual gradient ray). A percentage of 0%, or a length of 0, represents the center of the gradient, the value 100% the intersection of the ending shape with the virtual gradient ray. Percentage values in-between. are linearily positioned on the gradient ray.
Keywords describing how big the ending shape must be. The possible keywords are:
Constant Description
closest-side The gradient's ending shape meets the side of the box closest to its center (for circles) or meets both the vertical and horizontal sides closest to the center (for ellipses).
closest-corner The gradient's ending shape is sized so it exactly meets the closest corner of the box from its center.
farthest-side Similar to closest-side, except the ending shape is sized to meet the side of the box farthest from its center (or vertical and horizontal sides).
farthest-corner The gradient's ending shape is sized so it exactly meets the farthest corner of the box from its center.
Early drafts included other keywords (cover and contain) as synonyms of the standard farthest-corner and closest-side respectively. Use the standard keywords only, as some implementations have already dropped those older variants.


ellipse farthest-corner
background-image: -webkit-radial-gradient(45px 45px, ellipse farthest-corner, aqua 0%, rgba(0, 0, 255, 0) 50%, blue 95%);
background-image:         radial-gradient(45px 45px, ellipse farthest-corner, aqua 0%, rgba(0, 0, 255, 0) 50%, blue 95%);
470px 47px
background-image: -webkit-radial-gradient(470px 47px, ellipse farthest-corner, rgb(100%,100%,50%) 20%, rgba(90%,60%,60%,.4) 30%, rgb(90%,90%,100%) 60%);
background-image:         radial-gradient(470px 47px, ellipse farthest-corner, rgb(100%,100%,50%) 20%, rgba(80%,60%,60%,.4) 30%, rgb(90%,90%,100%) 60%);
background: -webkit-radial-gradient(45px 45px, farthest-corner, rgb(255, 0, 0) 0%, rgb(0, 0, 255) 100%);
background:         radial-gradient(45px 45px, farthest-corner, rgb(255, 0, 0) 0%, rgb(0, 0, 255) 100%);
16px radius fuzzy circle
background: -webkit-radial-gradient(circle 16px at 20px 50%, black 0%, black 14px, rgba(0,0,0,0.3) 18px, rgba(0,0,0,0) 19px);
background:         radial-gradient(circle 16px at 20px 50%, black 0%, black 14px, rgba(0,0,0,0.3) 18px, rgba(0,0,0,0) 19px);


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

Browser compatibility

Feature Firefox (Gecko) Chrome Internet Explorer Opera Safari
Basic support (support for the radial-gradient() function, but not necessary with the final syntax) 3.6 (1.9.2)-moz[4]
16 (16)
10.0 (534.16)-webkit [2][4] 10.0 [1] 11.60-o 5.1-webkit[2]
Legacy webkit syntax Not supported 3-webkit [2] Not supported Not supported 4.0-webkit[2]
at syntax (final standard syntax) 10 (10)-moz[4]
16 (16)
Not supported 10.0 11.60-o[4]
Presto 2.12 will remove the prefix.
Not supported

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

[2] WebKit since 528 supports the legacy -webkit-gradient(radial,…) function. See also their current support for radial gradients.

[4] Firefox 3.6 and Webkit implemented, prefixed, an early syntax.

See also

Document Tags and Contributors

Last updated by: Sheppy,