This feature is well established and works across many devices and browser versions. It’s been available across browsers since July 2015.
The SVGCircleElement interface is an interface for the <circle> element.
This interface also inherits properties from its parent, SVGGeometryElement.
SVGCircleElement.cx Read only
This property defines the x-coordinate of the center of the <circle> element. It is denoted by the cx attribute of the element.
SVGCircleElement.cy Read only
This property defines the y-coordinate of the center of the <circle> element. It is denoted by the cy attribute of the element.
SVGCircleElement.r Read only
This property defines the radius of the <circle> element. It is denoted by the r of the element.
Inherits methods from its parent interface, SVGGeometryElement.
In this example we draw a circle and randomly increase or decrease its radius when you click it.
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 250 250" width="250" height="250"> <circle cx="100" cy="100" r="50" fill="gold" id="circle" /> </svg>
const circle = document.getElementById("circle");
function clickCircle() {
// Randomly determine if the circle radius will increase or decrease
const change = Math.random() > 0.5 ? 10 : -10;
// Clamp the circle radius to a minimum of 10 and a maximum of 250,
// so it won't disappear or get bigger than the viewport
const newValue = Math.min(Math.max(circle.r.baseVal.value + change, 10), 250);
circle.setAttribute("r", newValue);
}
circle.addEventListener("click", clickCircle);
| Desktop | Mobile | |||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|
| Chrome | Edge | Firefox | Opera | Safari | Chrome Android | Firefox for Android | Opera Android | Safari on IOS | Samsung Internet | WebView Android | WebView on iOS | |
SVGCircleElement |
1 | 12 | 1.5 | 8 | 3 | 18 | 4 | 10.1 | 1 | 1.0 | 3 | 1 |
cx |
1 | 12 | 1.5 | ≤12.1 | 3 | 18 | 4 | ≤12.1 | 1 | 1.0 | 3 | 1 |
cy |
1 | 12 | 1.5 | ≤12.1 | 3 | 18 | 4 | ≤12.1 | 1 | 1.0 | 3 | 1 |
r |
1 | 12 | 1.5 | ≤12.1 | 3 | 18 | 4 | ≤12.1 | 1 | 1.0 | 3 | 1 |
<circle> SVG element
© 2005–2025 MDN contributors.
Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.
https://developer.mozilla.org/en-US/docs/Web/API/SVGCircleElement