SVG Circles and Ellipses

SVG provides dedicated elements for drawing perfect circles and ellipses: circle and ellipse. Both are simple to use and require just a few attributes.

The circle Element

A circle is defined by its center point and its radius. It has three core attributes:

The ellipse Element

An ellipse is like a circle that has been stretched in one direction. It is also defined by its center point, but instead of a single radius it has two separate radii (one for each axis):

Note: if you set rx and ry to the same value, you get a perfect circle, just like the circle element.

Basic Circle and Ellipse

Here is a circle and an ellipse drawn together to show the difference:

View Output

Adding Strokes

Just like rectangles, you can apply stroke, stroke-width, and stroke-dasharray to circles and ellipses to add borders and dashed outlines.

View Output

Attribute Summary

Element Attribute Description
circle cx X-coordinate of the center. Default is 0.
cy Y-coordinate of the center. Default is 0.
r Radius of the circle. Required.
ellipse cx X-coordinate of the center. Default is 0.
cy Y-coordinate of the center. Default is 0.
rx Horizontal radius. Required.
ry Vertical radius. Required.