Home SVG <circle> HTML SVG <circle> Definition
Definition and Usage The SVG <circle> element draws a circle from a center point (cx, cy) and a radius (r). Place it inside an <svg> .
Style with fill, stroke, and stroke-width (attributes or CSS). For ovals with unequal axes, use <ellipse> instead.
Baseline · Widely available. <circle> is a stable SVG basic shape across modern browsers since about July 2015.
SVG2 · Geometry as CSS. In SVG2, cx, cy, and r are also geometry properties — you can set them as CSS where supported.
Zero radius hides the circle. If r is missing, 0, or negative, nothing is drawn. Always set a positive radius.
Syntax
Syntax <svg width="200" height="200" viewBox="0 0 200 200"
xmlns="http://www.w3.org/2000/svg"
role="img" aria-label="Example circle">
<circle cx="100" cy="100" r="60"
fill="#2563eb" stroke="#0f172a" stroke-width="4" />
</svg> Self-closing <circle /> is fine in HTML. Keep meaningful aria-label (or title) when the graphic matters.
Reference
Attributes Core <circle> attributes:
Attribute Description Try it cxCenter X (default 0) Try itcyCenter Y (default 0) Try itrRadius; ≤ 0 disables rendering Try itfill / strokeInterior and outline colors Try itstroke-widthOutline thickness Try itpathLengthOptional path length for dash math Try it
Also supported
Global Attributes The <circle> tag also supports the Global Attributes in HTML (for example id, class, lang, title) when used in an HTML document.
Try it
Live Preview Change the radius and toggle stroke. The center stays fixed at (100, 100).
Code
HTML Examples Short, copy-ready snippets. Use Try It Yourself for a live editor.
1. Basic 2. Stroke 3. Multiple 4. Opacity 5. Dashed Example 1 — Basic Filled Circle Set center, radius, fill, and a light stroke.
<svg width="200" height="200" viewBox="0 0 200 200"
xmlns="http://www.w3.org/2000/svg"
role="img" aria-label="Blue filled circle">
<circle cx="100" cy="100" r="60"
fill="#2563eb" stroke="#0f172a" stroke-width="3" />
</svg> How It Works Create an <svg> with a matching viewBox.Set cx / cy to the center.Set r to the radius.Add fill and stroke for color and outline.Example 2 — Stroke Only Use fill="none" for a ring.
<svg width="200" height="200" viewBox="0 0 200 200"
xmlns="http://www.w3.org/2000/svg"
role="img" aria-label="Outlined circle ring">
<circle cx="100" cy="100" r="55"
fill="none" stroke="#16a34a" stroke-width="8" />
</svg> How It Works fill="none" leaves the interior empty.stroke draws the circumference.stroke-width sets thickness.Same cx, cy, r as a filled circle.Example 3 — Multiple Circles Several circles share one SVG coordinate system.
<svg width="280" height="140" viewBox="0 0 280 140"
xmlns="http://www.w3.org/2000/svg"
role="img" aria-label="Three colored circles">
<circle cx="60" cy="70" r="40" fill="#2563eb" />
<circle cx="140" cy="70" r="40" fill="#7c3aed" />
<circle cx="220" cy="70" r="40" fill="#ea580c" />
</svg> How It Works One <svg> holds every shape.Change cx to space circles horizontally.Keep cy and r equal for a neat row.Later shapes paint on top if they overlap.Example 4 — Overlap with Opacity Use fill-opacity to see overlapping areas.
<svg width="240" height="160" viewBox="0 0 240 160"
xmlns="http://www.w3.org/2000/svg"
role="img" aria-label="Overlapping semi-transparent circles">
<circle cx="95" cy="80" r="55" fill="#2563eb" fill-opacity="0.55" />
<circle cx="145" cy="80" r="55" fill="#facc15" fill-opacity="0.55" />
</svg> How It Works Two centers sit close so the disks overlap.fill-opacity="0.55" lets both colors show through.You can also use opacity on the whole element (fill + stroke).Useful for Venn-style diagrams and soft badges.Example 5 — Dashed Stroke Combine stroke-dasharray with a stroked circle.
<svg width="200" height="200" viewBox="0 0 200 200"
xmlns="http://www.w3.org/2000/svg"
role="img" aria-label="Dashed circle outline">
<circle cx="100" cy="100" r="60"
fill="none" stroke="#7c3aed" stroke-width="6"
stroke-dasharray="12 8" />
</svg> How It Works Stroke-only circle as in example 2.stroke-dasharray="12 8" means 12 on, 8 off.Optional pathLength can normalize dash math for animation.See also the SVG stroke page for more line styles. Edge Cases & Pitfalls Most missing-circle bugs are radius, viewport, or fill/stroke settings.
radius r must be positive Default r is 0. Zero or negative values disable rendering.
viewBox Stay inside the viewBox If the circle sits outside viewBox / SVG size, it is clipped or invisible. Size the SVG to fit cx ± r and cy ± r.
style fill none needs a stroke With fill="none" and no stroke, you see nothing. Set at least one visible paint.
units User units, not CSS px alone Coordinates live in the SVG user space. Prefer viewBox + CSS sizing over only hard-coded pixel layouts.
Compatibility
Browser Support The SVG <circle> element is supported in every modern browser.
✓ Baseline · Widely available
SVG <circle> Widely available since about July 2015. Chrome, Firefox, Safari, Edge, and Opera support circle geometry and presentation attributes. Internet Explorer 9+ supports basic SVG circles.
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 <circle> Widely supported
Bottom line: Safe for production icons, charts, and UI marks. Prefer attributes for teaching; CSS geometry properties are fine in modern browsers.
Remember
Key Takeaways Geometry: cx, cy, positive r.
Paint: fill, stroke, stroke-width.
Scale: parent viewBox + CSS size.
Oval? Use <ellipse> with rx/ry.
One line: center + radius + paint inside an <svg>.
UA style
Default CSS Settings SVG shapes use presentation defaults more than a browser CSS rule sheet. Typical initial paint:
/* Conceptual SVG defaults */
circle {
fill: black;
stroke: none;
stroke-width: 1;
} Set fill / stroke explicitly in examples so results stay predictable across contexts.
Frequently Asked Questions How do I draw a circle in SVG? Put a <circle> inside an <svg>. Set cx and cy for the center, r for the radius, then style with fill and/or stroke.
What do cx, cy, and r mean? cx and cy are the center coordinates. r is the radius. Defaults are 0. If r is 0 or less, the circle is not rendered.
How is circle different from ellipse? circle uses one radius (r). ellipse uses rx and ry. Prefer circle when both axes are equal.
Why is my circle invisible? Common causes: r is 0, the shape is outside the viewBox, fill is none with no stroke, or the SVG has zero width/height.
Can I style circle with CSS? Yes. Use presentation attributes or CSS (including SVG2 geometry properties cx, cy, and r as CSS where supported).
How do I make the circle responsive? Give the parent svg a viewBox, then size the svg with CSS. The vector circle scales cleanly.
Next: SVG Ellipse Learn rx and ry for ovals and stretched rings.
SVG Ellipse → About the author Developer, cloud engineer, and technical writer
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
Helpful Share Copy link Suggestion