<circle>
Core element
Place <circle> inside an <svg> canvas to draw a round shape.

SVG’s <circle> draws a perfect round shape from a center point and a radius. This tutorial covers the cx, cy, and r attributes, styling with fill / stroke, responsive viewBox usage, five worked examples, and how <circle> compares to <ellipse> and other basic shapes.
Core element
Place <circle> inside an <svg> canvas to draw a round shape.
Center point
Set the horizontal and vertical position of the circle’s center.
Radius
One radius value sizes a perfect circle in user units.
Presentation
Color the inside and outline with fill, stroke, and stroke-width.
Responsive
Scale circles cleanly with a viewBox and CSS sizing.
Any resolution
Circles stay crisp on retina screens because SVG is drawn as vectors.
SVG’s <circle> is one of the fundamental basic shapes in Scalable Vector Graphics. Unlike a bitmap, a circle is described mathematically — a center and a radius — so the browser can redraw it at any size without blur.
Circles power icons, avatars, chart markers, loaders, badges, and brand marks across the web. Once you know cx, cy, r, and a few presentation attributes, you can build most circular UI pieces from markup alone.
Raster circles pixelate when scaled. SVG circles stay sharp, stay tiny in file size, and can be styled or animated with CSS and JavaScript like any other DOM element.
cx, cy, and r fully define geometry.
Fill, stroke, opacity, and dashes work as attributes or CSS.
Add role="img" and an aria-label when the circle conveys meaning.
One drawing scales to any CSS size without rewriting coordinates.
In short: put a <circle> in an <svg>, set the center and radius, then style the fill and stroke — that’s the whole foundation.
Basic form of the SVG circle element:
<svg width="200" height="200">
<circle cx="100" cy="100" r="50" />
</svg> | Attribute | Type | Description |
|---|---|---|
cx | Length / number | x-coordinate of the center. Defaults to 0. |
cy | Length / number | y-coordinate of the center. Defaults to 0. |
r | Length / number | Radius of the circle. Defaults to 0 (invisible). |
fill | Paint | Interior color (or none for outline-only). |
stroke | Paint | Outline color of the circle. |
stroke-width | Length / number | Outline thickness in user units. |
| Result | Details |
|---|---|
| vector circle | Renders a perfect circle on the SVG canvas using the center and radius you provide. |
<svg width="200" height="200" viewBox="0 0 200 200">
<circle cx="100" cy="100" r="50"
fill="orange" stroke="black" stroke-width="2" />
</svg> | Idea | Detail | Notes |
|---|---|---|
| Origin | (0, 0) is top-left | y grows downward |
| Keep it visible | cx ± r and cy ± r | Stay inside width/height or viewBox |
Missing r | Defaults to 0 | Nothing is drawn |
| Goal | Code |
|---|---|
| Basic circle | <circle cx="100" cy="100" r="50" /> |
| Solid fill | <circle ... fill="#3b82f6" /> |
| Stroke only | <circle ... fill="none" stroke="#10b981" stroke-width="3" /> |
| Fill + stroke | <circle ... fill="#fde68a" stroke="#b45309" stroke-width="2" /> |
| Dashed outline | stroke-dasharray="6 4" |
| Responsive SVG | <svg viewBox="0 0 200 200">... + CSS width |
<circle> vs <ellipse> vs <rect> vs <path>All draw shapes — pick the simplest element that fits.
one radiusPerfect round shape with cx, cy, r
two radiiOval shapes with rx and ry
boxRectangles and rounded squares
any shapeArcs and custom outlines when primitives aren’t enough
<circle>Reach for <circle> whenever you need a true round shape in SVG.
Profile bubbles, status dots, and round icon backgrounds.
Scatter points, bubble charts, and donut / pie building blocks.
Stroke-dash circles for spinners and progress rings.
Layered circles for brand marks and notification dots.
If width and height differ, use <ellipse> instead.
Key benefit: one element, three attributes, sharp at any size — the simplest round shape in SVG.
Five starter snippets using <circle>. Click View Output for a preview, or Try It Yourself to edit live.
Draw your first circle and style the outline.
Draw an orange circle with a black border, centered at (100, 100) with radius 50 inside a 200×200 canvas.
<svg width="200" height="200">
<circle cx="100" cy="100" r="50"
fill="orange" stroke="black" stroke-width="2" />
</svg> The SVG sets a 200×200 drawing area. The circle’s center sits at the middle of that canvas, and radius 50 keeps the entire shape inside the bounds with room for the stroke.
Set fill="none" so only the outline appears — useful for rings and hollow icons.
<svg width="200" height="200">
<circle cx="100" cy="100" r="60"
fill="none" stroke="#10b981" stroke-width="4" />
</svg> With no fill, the browser draws only the path of the circumference. Without a stroke, a fill="none" circle would be invisible.
Combine styles, dashes, and responsive sizing.
Use a soft fill with a stronger outline for badges and highlighted markers.
<svg width="200" height="200">
<circle cx="100" cy="100" r="55"
fill="#fde68a" stroke="#b45309" stroke-width="3" />
</svg> fill paints the interior; stroke draws on top of the edge. Half of stroke-width sits inside the radius and half outside, so leave a little margin from the SVG edge.
Combine stroke-dasharray and fill-opacity for softer, decorative circles.
<svg width="220" height="120">
<circle cx="60" cy="60" r="40"
fill="#ef4444" fill-opacity="0.35"
stroke="#991b1b" stroke-width="2" />
<circle cx="160" cy="60" r="40"
fill="none" stroke="#6d28d9" stroke-width="3"
stroke-dasharray="6 4" />
</svg> fill-opacity fades the fill without changing the stroke. stroke-dasharray="6 4" draws 6-unit dashes with 4-unit gaps around the circumference.
Define coordinates in a viewBox, then let CSS control the displayed size so the circle scales cleanly.
<style>
.icon { width: 96px; height: auto; display: block; }
</style>
<svg class="icon" viewBox="0 0 100 100"
role="img" aria-label="Blue status circle">
<circle cx="50" cy="50" r="40" fill="#3b82f6" />
</svg> The viewBox maps user units 0–100 to whatever CSS size you give the SVG. Change .icon { width } and the circle scales without rewriting cx, cy, or r.
Real-world places where SVG circles show up every day.
Profile bubbles, status dots, and round icon backgrounds.
Example: online indicator next to a username.
Scatter points, bubble charts, and donut / pie segments.
Example: plot markers on an SVG chart.
Animate stroke-dashoffset for circular progress UI.
Example: indeterminate loading ring.
Notification dots, circular badges, and toggle indicators.
Example: unread count bubble.
Brand marks built from one or more layered circles.
Example: concentric rings as a wordmark icon.
Location pins, heat-map dots, and clustered markers.
Example: city dots on an SVG map.
Pro Tip: prefer <circle> for equal radii; switch to <ellipse> only when you need different rx and ry.
Why draw circles with SVG instead of images or CSS alone.
Vectors stay sharp on any screen density — no extra assets for 2x / 3x.
A few attributes replace PNG downloads for simple round graphics.
Style, animate, and update circles like any other DOM node.
Meaningful graphics can expose purpose via aria-label or <title>.
Layer circles with other SVG shapes for logos, charts, and icons.
Pro Tip: for UI icons, inline SVG circles plus currentColor often beat exporting separate PNGs for every theme.
Follow these practices for clean, scalable SVG circles.
Define geometry once, then size the SVG with CSS.
Thick strokes can clip at the SVG edge — pad the canvas or shrink r.
fill="currentColor" inherits the parent text color for easy theming.
Add role="img" and aria-label when the circle is not decorative.
Whole-pixel strokes (1, 2, 3…) usually look sharper at common sizes.
Pro Tip: decorative circles can use aria-hidden="true"; informative ones should explain themselves to assistive tech.
Avoid these mistakes when your circle refuses to show up.
rRadius defaults to 0, so the circle is invisible until you set it.
→ Always set a positive r (and a fill or stroke).
fill="none" With No StrokeNothing paints — outline-only circles need a visible stroke.
→ Pair fill="none" with stroke and stroke-width.
If cx + r exceeds the SVG size (or viewBox), parts get clipped.
→ Keep the full diameter inside the drawing area, including stroke.
Missing width/height and no CSS size leaves an empty box.
→ Set dimensions on the SVG or size it with CSS.
SVG origin is top-left; y increases downward — not Cartesian-up like some math graphs.
→ Treat (0, 0) as the top-left of the canvas.
Pro Tip: if a circle vanishes, check r, fill/stroke, and whether the center sits inside the viewBox — those three catch most issues.
<circle> Is DrawnWrap your shape in an <svg>. Give it a width and height (or a viewBox) so the browser knows the drawing area.
cx is horizontal position; cy is vertical. Origin (0, 0) is the top-left corner.
r defines size in user units. Keep cx ± r and cy ± r inside the bounds to avoid clipping.
Use fill for the inside, stroke for the outline, and stroke-width for thickness. Set fill="none" for outline-only.
The browser draws the vector live from center, radius, and paint values — sharp at every zoom level.
cx, cy, and r default to 0 — always set a positive radius.stroke-width sits outside the radius and can clip near edges.<ellipse>, not <circle>.viewBox when the graphic must scale responsively.Quick Takeaway: center + radius + paint. Keep the circle inside the viewBox, and use CSS sizing for responsive icons.
The SVG <circle> element is supported in all modern browsers — and has been for many years — as part of SVG 1.1 basic shapes.
Use
Bottom line: Safe for production sites. Prefer inline SVG or cached .svg assets; no polyfill is required for current browsers.
SVG <circle> is the simplest way to draw a perfect round shape on the web: set cx, cy, and r, then style with fill and stroke.
Practice the five examples above, then continue to SVG Ellipse when you need different horizontal and vertical radii.
Always set a positive r, leave room for strokes, and use viewBox when the circle must scale with the layout.
viewBox on the parent <svg> for responsive scalingrole="img" and aria-label for meaningful graphicscurrentColor for themingcx ± r and cy ± r inside the canvas(0, 0) is the top-left cornerfill="none" without a stroker attribute — it defaults to 0<circle>Draw perfect circles the SVG way.
Basic SVG shape
APIcx & cy
PositionOne size value
Sizefill & stroke
StyleScales cleanly
ResponsiveAn SVG <circle> is defined by a center (cx, cy) and a radius (r) — three numbers draw a perfect, resolution-independent circle. You can also animate r, cx, or stroke-dashoffset with CSS or SMIL to build loaders and pulse effects without images.
Learn how rx and ry create ovals when a single radius isn’t enough.
9 people found this page helpful