SVG Ellipse

What You’ll Learn
How to create and customize SVG ellipses in HTML using the <ellipse> element. Ellipses are like stretched circles and are useful for smooth, rounded visuals in icons, diagrams, and data visualisations.
You’ll learn the syntax, the four core attributes (cx, cy, rx, ry), styling with fill, stroke, and stroke-width, plus a complete example, live preview, and best practices.
⚡ Quick Reference — SVG Ellipse Attributes
numberx-coordinate of the centre
numbery-coordinate of the centre
numberHorizontal radius (x-axis)
numberVertical radius (y-axis)
colorInside fill colour
colorOutline colour
numberOutline thickness in pixels
<svg>
<ellipse cx="center-x" cy="center-y" rx="x-radius" ry="y-radius" />
</svg>Complete HTML Example
This example draws a green ellipse with a black border, centered at (100, 75) with radii rx=80 and ry=50 inside a 200×150 SVG canvas:
<!DOCTYPE html>
<html>
<body>
<svg width="200" height="150">
<ellipse cx="100" cy="75" rx="80" ry="50" fill="green" stroke="black" stroke-width="2" />
</svg>
</body>
</html>👀 Live Preview — Ellipse Variations
See how changing rx and ry (and styling) affects the shape:
🧠 How It Works
Create an SVG canvas
Place the ellipse inside an <svg>. Use width/height or a viewBox so the browser knows the coordinate space.
Position the center (cx, cy)
cx and cy set the centre point. Like all SVG coordinates, (0, 0) is at the top-left.
Set two radii (rx, ry)
rx defines half the width and ry defines half the height. If either value is missing or 0, the ellipse won’t render.
Style with fill and stroke
Use fill for the inside and stroke/stroke-width for the outline. Set fill=\"none\" for outline-only ellipses.
A smooth, scalable ellipse
Ellipses are vector shapes, so they scale cleanly for icons, UI, and illustrations without pixelation.
Use Cases
Ellipses are especially useful when you need a circle-like shape that is stretched horizontally or vertically:
Scatterplot points, bubbles, and decorative markers.
Tag and badge shapes (often used as backgrounds).
Glow and highlight layers behind icons/text.
Shadows, faces/eyes, and soft rounded elements.
Elliptical rings and progress frames.
Geometry diagrams and coordinate-space demos.
💡 Best Practices
Do
- Use a
viewBoxfor responsive SVGs - Add
role=\"img\"andaria-labelfor meaningful graphics - Keep
rxandryinside the canvas to avoid clipping - Use CSS classes for consistent styling across multiple ellipses
- Prefer
fill=\"none\"with a stroke for outline-only visuals
Don’t
- Omit
rxorry— the ellipse becomes invisible - Assume an ellipse is a circle (a circle needs
<circle>withr) - Place the center too close to the edge if you want the full ellipse visible
- Use fixed pixel sizes when you need a responsive icon
- Set
fill=\"none\"without a stroke
Key Takeaways
An ellipse uses two radii
rx ryPosition it with cx and cy
Style it with fill and stroke settings
If rx or ry is 0, nothing renders
Use a viewBox for scalable graphics
❓ Frequently Asked Questions
<ellipse> inside an <svg>. Set cx and cy for the centre and rx/ry for the radii. Example: <ellipse cx="100" cy="75" rx="80" ry="50" />.cx/cy set the centre point. rx is the horizontal radius and ry is the vertical radius. If either radius is missing or 0, the ellipse won’t render.<circle> uses one radius (r) and is always round. An <ellipse> uses two radii (rx, ry) so it can be stretched wider or taller.fill, stroke, and stroke-width directly on the element or via CSS selectors. CSS also enables hover states and animations.rx and ry are not 0, your ellipse is within the SVG bounds (or viewBox), and you’re not using fill="none" without a stroke. Also ensure the parent <svg> has a visible size.Level Up Your SVG Skills!
Next, explore filters to add shadows, blur, and pro-level effects to your shapes.
7 people found this page helpful
