HTML SVG <radialGradient>

Beginner
9 min read
Updated: Nov 2026
5 examples
Live preview

Definition and Usage

The SVG <radialGradient> element defines a reusable color blend that radiates from a center. Put it in <defs>, give it an id, add <stop> colors, then paint shapes with fill="url(#id)" or stroke="url(#id)".

Center and size come from cx, cy, and r (defaults 50%). Use fx/fy for a highlight. For straight blends, see linear gradients.

Baseline · Widely available.

<radialGradient> and <stop> are stable across modern browsers since about July 2015.

Deprecated: xlink:href.

Do not reuse gradients with xlink:href. Prefer a full local definition, or the modern href attribute when you need a template reference.

Not CSS radial-gradient().

SVG radialGradient paints SVG shapes. CSS radial-gradient() paints HTML boxes. They are separate APIs.

Syntax

radial-gradient.html
<svg width="200" height="200" viewBox="0 0 200 200"
     xmlns="http://www.w3.org/2000/svg"
     role="img" aria-label="Circle with radial gradient fill">
  <defs>
    <radialGradient id="rg1" cx="50%" cy="50%" r="50%">
      <stop offset="0%" stop-color="#facc15" />
      <stop offset="100%" stop-color="#ea580c" />
    </radialGradient>
  </defs>
  <circle cx="100" cy="100" r="80" fill="url(#rg1)" />
</svg>

Pattern: define stops → unique id → apply with url(#id).

Attributes

Core radial gradient pieces:

NameDescriptionTry it
idHandle for url(#…)Try it
cx cy rEnd-circle center and radius (default 50%)Try it
fx fyStart-circle (focal) position; default equals cx/cyTry it
frStart-circle radius (default 0%)Try it
<stop> offsetPosition of a color from center to edgeTry it
stop-color / stop-opacityColor and transparency of a stopTry it
gradientUnitsobjectBoundingBox (default) or userSpaceOnUseTry it
fill / stroke url(#id)Apply the gradient to a shapeTry it

Global Attributes

The <radialGradient> tag also supports the Global Attributes in HTML (for example id, class, lang, title) when used in an HTML document.

Live Preview

Change the outer radius and the focal point. Center stays at (50%, 50%).

50
50

Defaults match MDN: cx/cy/r at 50%, focus at the center.

SVG

r="50%" fx="50%"

HTML Examples

Short, copy-ready snippets. Use Try It Yourself for a live editor.

Example 1 — Basic Center Fill

Two stops paint a circle from center to edge.

HTML
<svg width="200" height="200" viewBox="0 0 200 200"
     xmlns="http://www.w3.org/2000/svg"
     role="img" aria-label="Centered radial gradient circle">
  <defs>
    <radialGradient id="orb" cx="50%" cy="50%" r="50%">
      <stop offset="0%" stop-color="#facc15" />
      <stop offset="100%" stop-color="#ea580c" />
    </radialGradient>
  </defs>
  <circle cx="100" cy="100" r="80" fill="url(#orb)" />
</svg>
Try It Yourself

How It Works

  1. Define <radialGradient id="orb"> in <defs>.
  2. Set cx/cy/r to 50% for a centered blend.
  3. Add two <stop> colors at 0% and 100%.
  4. Apply with fill="url(#orb)".

Example 2 — Focal Highlight

Offset fx and fy to mimic a light source.

HTML
<svg width="200" height="200" viewBox="0 0 200 200"
     xmlns="http://www.w3.org/2000/svg"
     role="img" aria-label="Radial gradient with offset focal point">
  <defs>
    <radialGradient id="lit" cx="50%" cy="50%" r="50%" fx="35%" fy="35%">
      <stop offset="0%" stop-color="#ffffff" />
      <stop offset="100%" stop-color="#2563eb" />
    </radialGradient>
  </defs>
  <circle cx="100" cy="100" r="80" fill="url(#lit)" />
</svg>
Try It Yourself

How It Works

  1. Keep cx/cy centered so the outer circle stays put.
  2. Move fx/fy toward a corner for the bright spot.
  3. Use a light start stop so the highlight reads clearly.
  4. The blend still ends at the outer circle defined by r.

Example 3 — Multiple Stops

Three colors create a richer orb.

HTML
<svg width="200" height="200" viewBox="0 0 200 200"
     xmlns="http://www.w3.org/2000/svg"
     role="img" aria-label="Three-stop radial gradient">
  <defs>
    <radialGradient id="glow" cx="50%" cy="50%" r="50%">
      <stop offset="0%" stop-color="#ffffff" />
      <stop offset="45%" stop-color="#a855f7" />
      <stop offset="100%" stop-color="#0f172a" />
    </radialGradient>
  </defs>
  <circle cx="100" cy="100" r="80" fill="url(#glow)" />
</svg>
Try It Yourself

How It Works

  1. Add as many <stop> as you need.
  2. Order by offset from center (0%) to edge (100%).
  3. Mid stops control the transition colors.
  4. Optional stop-opacity fades a stop.

Example 4 — Gradient on Stroke

Paint a thick outline instead of a fill.

HTML
<svg width="200" height="200" viewBox="0 0 200 200"
     xmlns="http://www.w3.org/2000/svg"
     role="img" aria-label="Circle stroked with a radial gradient">
  <defs>
    <radialGradient id="ring" cx="50%" cy="50%" r="50%">
      <stop offset="0%" stop-color="#facc15" />
      <stop offset="100%" stop-color="#16a34a" />
    </radialGradient>
  </defs>
  <circle cx="100" cy="100" r="60"
          fill="none" stroke="url(#ring)" stroke-width="18" />
</svg>
Try It Yourself

How It Works

  1. Define the gradient as usual.
  2. Set fill="none" so only the outline shows.
  3. Use stroke="url(#ring)" instead of fill.
  4. Increase stroke-width so the blend is easy to see.

Example 5 — Focal Radius (fr)

fr sets how large the start circle is before the blend begins.

HTML
<svg width="200" height="200" viewBox="0 0 200 200"
     xmlns="http://www.w3.org/2000/svg"
     role="img" aria-label="Radial gradient with focal radius">
  <defs>
    <radialGradient id="core" cx="50%" cy="50%" r="50%"
                    fx="35%" fy="35%" fr="15%">
      <stop offset="0%" stop-color="#ffffff" />
      <stop offset="100%" stop-color="#0f766e" />
    </radialGradient>
  </defs>
  <circle cx="100" cy="100" r="80" fill="url(#core)" />
</svg>
Try It Yourself

How It Works

  1. 0% stop maps to the start circle defined by fx, fy, and fr.
  2. 100% stop maps to the end circle defined by cx, cy, and r.
  3. Larger fr keeps the first color solid longer before blending.
  4. Default fr is 0% (a point focus).

Edge Cases & Pitfalls

Most broken radials are ids, missing url(), or unit surprises.

id

url(#id) must match

Typos or duplicate ids mean a solid black/default fill instead of your blend.

units

objectBoundingBox is default

Percent cx/r scale with the shape. Non-square boxes can make rings look elliptical. Use userSpaceOnUse for fixed coordinates.

focus

Keep the focus inside the end circle

If fx/fy sit outside the circle of radius r, browsers clamp the focus — the highlight may look unexpected.

stroke

Thin strokes hide blends

When using stroke="url(#id)", raise stroke-width so the gradient band is visible.

Browser Support

SVG <radialGradient> is supported in every modern browser.

✓ Baseline · Widely available

SVG <radialGradient>

Widely available since about July 2015. Chrome, Firefox, Safari, Edge, and Opera support radialGradient, stop, and url(#id) paint servers. Internet Explorer 9+ supports basic SVG gradients. The fr attribute is newer; older engines may treat it as 0%.

98% Global support (approx.)
Google Chrome All modern
Full support
Mozilla Firefox All modern
Full support
Apple Safari All modern
Full support
Microsoft Edge All modern
Full support
Opera All modern
Full support
Samsung Internet All modern
Full support
Internet Explorer 9+
Supported
<radialGradient> Widely supported

Bottom line: Safe for production icons, glows, and UI fills. Prefer local defs with unique ids over deprecated xlink:href reuse.

Key Takeaways

  • Define in <defs> with an id.
  • Geometry: cx, cy, r (+ optional fx/fy/fr).
  • Colors: <stop offset stop-color>.
  • Apply: fill or stroke url(#id).

One line: stops in <radialGradient>, paint with url(#id).

Default CSS Settings

Gradients are paint servers — they have no visible box of their own. Useful defaults to remember:

defaults.css
/* Conceptual defaults */
radialGradient {
  /* cx=50% cy=50% r=50%  → centered */
  /* fx/fy default to cx/cy; fr=0% */
  /* gradientUnits: objectBoundingBox */
  /* spreadMethod: pad */
}

/* Apply from CSS if needed */
.shape {
  fill: url(#orb);
}

Prefer presentation attributes in these lessons so the paint stays inside the SVG markup.

Frequently Asked Questions

Define a <radialGradient> in <defs> with an id and <stop> elements, then use fill="url(#id)" or stroke="url(#id)" on a shape.
cx and cy set the end-circle center. r sets its radius. Defaults are 50% when using objectBoundingBox units.
They move the start (focal) circle. Offsetting them from cx/cy creates a highlight like a light source.
offset places that color from the start circle (often the center) out to the end circle, usually as 0%, 50%, or 100%.
SVG radialGradient paints SVG shapes via url(#id). CSS radial-gradient() paints HTML/CSS boxes. They are not interchangeable.
Use radial when color should radiate from a center (orbs, glows, vignettes). Use linear for directional blends.

Next: Advanced

Browse interactivity and links, then open each guide.

Advanced →

About the author

Mari Selvan M P
Mari Selvan M P 🔗

Developer, cloud engineer, and technical writer

  • Experience 12 years building web and cloud systems
  • Focus Full Stack Development, AWS, and Developer Education

I write practical tutorials so students and working developers can learn by doing—from databases and APIs to deployment on AWS.

8 people found this page helpful