HTML SVG <ellipse>

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

Definition and Usage

The SVG <ellipse> element draws an oval from a center (cx, cy) and two radii (rx, ry). Place it inside an <svg>.

When rx equals ry, it looks like a circle — prefer <circle> in that case. Style with fill, stroke, and stroke-width.

Baseline · Widely available.

<ellipse> is a stable SVG basic shape across modern browsers since about July 2015.

SVG2 · Geometry as CSS.

In SVG2, cx, cy, rx, and ry are also geometry properties — you can set them as CSS where supported.

No built-in tilt.

rx/ry alone stay axis-aligned. Rotate with transform (for example rotate(45 cx cy)).

Zero radius hides the ellipse.

If rx or ry is 0 or less, nothing is drawn. Set both to positive values.

Syntax

ellipse.html
<svg width="240" height="160" viewBox="0 0 240 160"
     xmlns="http://www.w3.org/2000/svg"
     role="img" aria-label="Example ellipse">
  <ellipse cx="120" cy="80" rx="90" ry="45"
           fill="#16a34a" stroke="#0f172a" stroke-width="3" />
</svg>

Self-closing <ellipse /> is fine in HTML. Keep a clear aria-label when the graphic matters.

Attributes

Core <ellipse> attributes:

AttributeDescriptionTry it
cxCenter X (default 0)Try it
cyCenter Y (default 0)Try it
rxHorizontal radius; ≤ 0 disables renderingTry it
ryVertical radius; ≤ 0 disables renderingTry it
fill / strokeInterior and outline colorsTry it
transformRotate or move (needed to tilt)Try it
pathLengthOptional path length for dash mathTry it

Global Attributes

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

Live Preview

Adjust rx and ry. The center stays fixed at (120, 80).

90
45

Equal rx and ry look circular; unequal values make an oval.

SVG

cx="120" cy="80" rx="90" ry="45"

HTML Examples

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

Example 1 — Basic Filled Ellipse

Set center, both radii, fill, and a light stroke.

HTML
<svg width="240" height="160" viewBox="0 0 240 160"
     xmlns="http://www.w3.org/2000/svg"
     role="img" aria-label="Green filled ellipse">
  <ellipse cx="120" cy="80" rx="90" ry="45"
           fill="#16a34a" stroke="#0f172a" stroke-width="3" />
</svg>
Try It Yourself

How It Works

  1. Create an <svg> with a matching viewBox.
  2. Set cx / cy to the center.
  3. Set rx and ry for width and height of the oval.
  4. Add fill and stroke for color and outline.

Example 2 — Stroke Only

Use fill="none" for an oval ring.

HTML
<svg width="240" height="160" viewBox="0 0 240 160"
     xmlns="http://www.w3.org/2000/svg"
     role="img" aria-label="Outlined ellipse ring">
  <ellipse cx="120" cy="80" rx="85" ry="40"
           fill="none" stroke="#2563eb" stroke-width="6" />
</svg>
Try It Yourself

How It Works

  1. fill="none" leaves the interior empty.
  2. stroke draws the outline.
  3. stroke-width sets thickness.
  4. Same geometry as a filled ellipse: cx, cy, rx, ry.

Example 3 — Equal Radii (Looks Like a Circle)

When rx equals ry, the shape is circular.

HTML
<svg width="200" height="200" viewBox="0 0 200 200"
     xmlns="http://www.w3.org/2000/svg"
     role="img" aria-label="Ellipse with equal radii">
  <ellipse cx="100" cy="100" rx="55" ry="55"
           fill="#7c3aed" stroke="#0f172a" stroke-width="3" />
</svg>
Try It Yourself

How It Works

  1. Set the same value for rx and ry.
  2. The oval collapses into a circle visually.
  3. Prefer <circle> with one r when both axes match.
  4. Keep <ellipse> when you may change one radius later.

Example 4 — Multiple Ellipses

Several ellipses share one SVG coordinate system.

HTML
<svg width="280" height="140" viewBox="0 0 280 140"
     xmlns="http://www.w3.org/2000/svg"
     role="img" aria-label="Three colored ellipses">
  <ellipse cx="60" cy="70" rx="45" ry="30" fill="#2563eb" />
  <ellipse cx="140" cy="70" rx="45" ry="30" fill="#16a34a" />
  <ellipse cx="220" cy="70" rx="45" ry="30" fill="#ea580c" />
</svg>
Try It Yourself

How It Works

  1. One <svg> holds every shape.
  2. Change cx to space ellipses horizontally.
  3. Reuse cy, rx, and ry for a neat row.
  4. Later shapes paint on top if they overlap.

Example 5 — Rotated Ellipse

Tilt with transform="rotate(...)" around the center.

HTML
<svg width="240" height="160" viewBox="0 0 240 160"
     xmlns="http://www.w3.org/2000/svg"
     role="img" aria-label="Rotated ellipse">
  <ellipse cx="120" cy="80" rx="90" ry="35"
           fill="#facc15" stroke="#0f172a" stroke-width="3"
           transform="rotate(-30 120 80)" />
</svg>
Try It Yourself

How It Works

  1. Draw a normal ellipse with cx, cy, rx, ry.
  2. Add transform="rotate(angle cx cy)" to tilt it.
  3. Use the same center in rotate so it spins in place.
  4. Angles are degrees; negative values rotate the other way.

Edge Cases & Pitfalls

Most missing-ellipse bugs are radii, viewport, or fill/stroke settings.

radii

rx and ry must be positive

Either radius at 0 or less disables rendering. Always set both.

viewBox

Stay inside the viewBox

Fit the SVG around cx ± rx and cy ± ry (plus room after rotation).

tilt

Axis-aligned by default

You cannot angle the oval with rx/ry alone. Use transform.

style

fill none needs a stroke

With fill="none" and no stroke, you see nothing. Set at least one visible paint.

Browser Support

The SVG <ellipse> element is supported in every modern browser.

✓ Baseline · Widely available

SVG <ellipse>

Widely available since about July 2015. Chrome, Firefox, Safari, Edge, and Opera support ellipse geometry and presentation attributes. Internet Explorer 9+ supports basic SVG ellipses.

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
<ellipse> Widely supported

Bottom line: Safe for production icons, charts, and UI marks. Prefer attributes for teaching; CSS geometry properties are fine in modern browsers.

Key Takeaways

  • Geometry: cx, cy, positive rx and ry.
  • Paint: fill, stroke, stroke-width.
  • Scale: parent viewBox + CSS size.
  • Circle? Use <circle>; tilt? use transform.

One line: center + two radii + paint inside an <svg>.

Default CSS Settings

SVG shapes use presentation defaults more than a browser CSS rule sheet. Typical initial paint:

defaults.css
/* Conceptual SVG defaults */
ellipse {
  fill: black;
  stroke: none;
  stroke-width: 1;
}

Set fill / stroke explicitly in examples so results stay predictable across contexts.

Frequently Asked Questions

Put an <ellipse> inside an <svg>. Set cx and cy for the center, rx for the horizontal radius, ry for the vertical radius, then style with fill and/or stroke.
cx and cy are the center. rx is the x-axis radius; ry is the y-axis radius. If either radius is 0 or less, the ellipse is not rendered.
circle uses one radius (r). ellipse uses rx and ry. Prefer circle when both axes are equal; use ellipse for ovals.
Not with rx/ry alone. Rotate it with the transform attribute (for example rotate(45 cx cy)).
Common causes: rx or ry is 0, the shape is outside the viewBox, fill is none with no stroke, or the SVG has zero width/height.
Yes. Use presentation attributes or CSS (including SVG2 geometry properties cx, cy, rx, and ry as CSS where supported).

Next: SVG Line

Learn x1, y1, x2, and y2 for straight segments.

SVG Line →

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