svg element
<radialGradient>
The <radialGradient> SVG element lets authors define radial gradients that can be applied to fill or stroke of graphical elements.
[!NOTE] Don’t be confused with CSS
radial-gradient()as CSS gradients can only apply to HTML elements where SVG gradient can only apply to SVG elements.
Usage context
Attributes
cx- : This attribute defines the x coordinate of the end circle of the radial gradient.
Value type: <length>; Default value:
50%; Animatable: yes
- : This attribute defines the x coordinate of the end circle of the radial gradient.
Value type: <length>; Default value:
cy- : This attribute defines the y coordinate of the end circle of the radial gradient.
Value type: <length>; Default value:
50%; Animatable: yes
- : This attribute defines the y coordinate of the end circle of the radial gradient.
Value type: <length>; Default value:
fr- : This attribute defines the radius of the start circle of the radial gradient. The gradient will be drawn such that the 0%
<gradient stop>is mapped to the perimeter of the start circle. Value type: <length>; Default value:0%; Animatable: yes
- : This attribute defines the radius of the start circle of the radial gradient. The gradient will be drawn such that the 0%
fx- : This attribute defines the x coordinate of the start circle of the radial gradient.
Value type: <length>; Default value: Same as
cx; Animatable: yes
- : This attribute defines the x coordinate of the start circle of the radial gradient.
Value type: <length>; Default value: Same as
fy- : This attribute defines the y coordinate of the start circle of the radial gradient.
Value type: <length>; Default value: Same as
cy; Animatable: yes
- : This attribute defines the y coordinate of the start circle of the radial gradient.
Value type: <length>; Default value: Same as
gradientUnits- : This attribute defines the coordinate system for attributes
cx,cy,r,fx,fy,frValue type:userSpaceOnUse|objectBoundingBox; Default value:objectBoundingBox; Animatable: yes
- : This attribute defines the coordinate system for attributes
gradientTransform- : This attribute provides additional transformation to the gradient coordinate system. Value type: <transform-list>; Default value: identity transform; Animatable: yes
href- : This attribute defines a reference to another
<radialGradient>element that will be used as a template. Value type: <URL>; Default value: none; Animatable: yes
- : This attribute defines a reference to another
r- : This attribute defines the radius of the end circle of the radial gradient. The gradient will be drawn such that the 100%
<gradient stop>is mapped to the perimeter of the end circle. Value type: <length>; Default value:50%; Animatable: yes
- : This attribute defines the radius of the end circle of the radial gradient. The gradient will be drawn such that the 100%
spreadMethod- : This attribute indicates how the gradient behaves if it starts or ends inside the bounds of the shape containing the gradient.
Value type:
pad|reflect|repeat; Default value:pad; Animatable: yes
- : This attribute indicates how the gradient behaves if it starts or ends inside the bounds of the shape containing the gradient.
Value type:
xlink:hrefDeprecated
DOM Interface
This element implements the SVGRadialGradientElement interface.
Example
html,
body,
svg {
height: 100%;
}
<svg
viewBox="0 0 10 10"
xmlns="http://www.w3.org/2000/svg"
xmlns:xlink="http://www.w3.org/1999/xlink">
<defs>
<radialGradient id="myGradient">
<stop offset="10%" stop-color="gold" />
<stop offset="95%" stop-color="red" />
</radialGradient>
</defs>
<!-- using my radial gradient -->
<circle cx="5" cy="5" r="4" fill="url('#myGradient')" />
</svg>
Interactive exampleOpen the canonical MDN source to run this embedded demo.
Specifications
SpecificationsStandards references are available on the canonical MDN page.
Browser compatibility
Browser compatibilityCompatibility data is available on the canonical MDN page.