Easy Tutorial
❮ Svg Circle Svg Text ❯

SVG Gradients - Radial


SVG Radial Gradient - <radialGradient>

The <radialGradient> element is used to define a radial gradient.

The <radialGradient> tag must be nested inside a <defs> element. The <defs> tag stands for definitions and is used to define special elements like gradients.


Example 1

Define a radial gradient from white to blue for an ellipse:

Here is the SVG code:

Example

<svg xmlns="http://www.w3.org/2000/svg" version="1.1">
 
<defs>
   
<radialGradient id="grad1" cx="50%" cy="50%" r="50%"
fx="50%" fy="50%">
     
&lt;stop offset="0%" style="stop-color:rgb(255,255,255);
      stop-opacity:0" />
     
<stop offset="100%" style="stop-color:rgb(0,0,255);stop-opacity:1" />
   
</radialGradient>
 
</defs>
 
<ellipse cx="200" cy="70" rx="85" ry="55"
fill="url(#grad1)" />
</svg>

For Opera users: View SVG file (right-click on the SVG graphic to preview the source).

Code Analysis:


Example 2

Define another radial gradient from white to blue for an ellipse:

Here is the SVG code:

Example

<svg xmlns="http://www.w3.org/2000/svg" version="1.1">
 
<defs>
   
<radialGradient id="grad1" cx="20%" cy="30%" r="30%"
fx="50%" fy="50%">
     
&lt;stop offset="0%" style="stop-color:rgb(255,255,255);
      stop-opacity:0" />
     
<stop offset="100%" style="stop-color:rgb(0,0,255);stop-opacity:1" />
   
</radialGradient>
 
</defs>
 
<ellipse cx="200" cy="70" rx="85" ry="55" fill="url(#grad1)" />
</svg>

For Opera users: View SVG file (right-click on the SVG graphic to preview the source).

❮ Svg Circle Svg Text ❯