Introduction
Before reading further, read the following articles.
- Overview of Scalable Vector Graphics (SVG)
- Scalable Vector Graphics - Rectangle
- Scalable Vector Graphics - Circle
Now let’s discuss SVG Ellipse.
The tag <ellipse> is used here to create an ellipse with a center point and two radii. As we can see that an ellipse is closely related to a circle as it also has a center point and a radius, but there are some differences that an ellipse has two radii x and y that differs from each other while circle has both radii x and y equal or considered as only one radius due to equality.
In other words, an ellipse is a circle that does not have equal height and width, as well as its radius in x and y directions, are different.
Syntax:
SVG Ellipse
- <svg height="200" width="300">
- <ellipse cx="150" cy="70" rx="80" ry="40" style="fill:red" />
- </svg>
- cx and cy are the attributes which define the x and y coordinates of the center of the ellipse.
- rx and ry are the attributes which define the horizontal and vertical radii of ellipse respectively.
Now let’s take a simple example to understand it properly.
Example 1
Regular ellipse:
- <html>
- <body>
- <svg height="150" width="550">
- <ellipse cx="110" cy="80" rx="100" ry="50" style="fill:cyan;" />
- <ellipse cx="300" cy="80" rx="80" ry="40" style="fill:lime;" />
- <ellipse cx="450" cy="80" rx="60" ry="30" style="fill:pink;" />
- </svg>
- </body>
- </html>

- <html>
- <body>
- <svg height="300" width="500">
- <ellipse cx="60" cy="130" rx="30" ry="70" style="fill:grey;" />
- <ellipse cx="160" cy="130" rx="40" ry="90" style="fill:tomato;" />
- <ellipse cx="280" cy="130" rx="50" ry="110" style="fill:lightgreen;" />
- </svg>
- </body>
- </html>

- <html>
- <body>
- <svg height="150" width="550">
- <ellipse cx="110" cy="80" rx="100" ry="50" style="fill:red; stroke:black; stroke-width:2" />
- <ellipse cx="300" cy="80" rx="80" ry="40" style="fill:orange; stroke:blue; stroke-width:4" />
- <ellipse cx="450" cy="80" rx="60" ry="30" style="fill:yellow; stroke:purple; stroke-width:7" />
- </svg>
- </body>
- </html>

- <html>
- <body>
- <svg height="150" width="550">
- <ellipse cx="110" cy="80" rx="100" ry="50" style="fill:lightgreen; stroke:green; stroke-width:2; stroke-dasharray: 10 2;" />
- <ellipse cx="300" cy="80" rx="80" ry="40" style="fill:lightblue; stroke:blue; stroke-width:4; stroke-dasharray: 10 4;" />
- <ellipse cx="455" cy="80" rx="60" ry="30" style="fill:tomato; stroke:red; stroke-width:7; stroke-dasharray: 10 6;" />
- </svg>
- </body>
- </html>

- <html>
- <body>
- <svg height="300" width="300">
- <ellipse cx="110" cy="220" rx="50" ry="15" style="fill:tomato; stroke:red; stroke-width:3;" />
- <ellipse cx="110" cy="180" rx="100" ry="40" style="fill:tomato; stroke:red; stroke-width:3;" />
- <ellipse cx="110" cy="100" rx="20" ry="80" style="fill:yellow; stroke:orange; stroke-width:6; stroke-dasharray: 10 5;" />
- </svg>
- </body>
- </html>

- <html>
- <body>
- <svg height="300" width="600">
- <ellipse cx="60" cy="110" rx="30" ry="100" style="fill:none; stroke:red; stroke-width:6;stroke-dasharray: 10 5;" />
- <ellipse cx="200" cy="110" rx="80" ry="30" style="fill:none; stroke:black; stroke-width:4;" />
- <ellipse cx="340" cy="110" rx="30" ry="80" style="fill:none; stroke:blue; stroke-width:3; stroke-dasharray: 10 5;" />
- </svg>
- </body>
- </html>

- <html>
- <body>
- <svg height="400" width="1000">
- <ellipse cx="180" cy="120" rx="150" ry="30" style="fill:lime; stroke:green; stroke-width:3;" />
- <ellipse cx="150" cy="90" rx="120" ry="25" style="fill:tomato" />
- <ellipse cx="120" cy="65" rx="90" ry="20" style="fill:cyan; stroke:blue; stroke-width:3; stroke-dasharray:10 5;" />
- <ellipse cx="100" cy="45" rx="70" ry="15" style="fill:grey" />
- <ellipse cx="80" cy="25" rx="50" ry="10" style="fill:orange; stroke:red; stroke-width:3;" />
- <ellipse cx="500" cy="120" rx="150" ry="30" style="fill:orange; stroke:red; stroke-width:3;" />
- <ellipse cx="500" cy="90" rx="120" ry="25" style="fill:grey" />
- <ellipse cx="500" cy="65" rx="90" ry="20" style="fill:cyan; stroke:blue; stroke-width:3; stroke-dasharray:10 5;" />
- <ellipse cx="500" cy="45" rx="70" ry="15" style="fill:tomato" />
- <ellipse cx="500" cy="25" rx="50" ry="10" style="fill:lime; stroke:green; stroke-width:3;" />
- </svg>
- </body>
- </html>

- <html>
- <body>
- <svg height="400" width="1000">
- <ellipse cx="70" cy="50" rx="50" ry="30" style="stroke:green; stroke-width: 3; fill:lightgreen;"/>
- <ellipse cx="80" cy="60" rx="50" ry="30" style="stroke: #ffff00; stroke-width: 5; stroke-dasharray:10 5; fill: none;"/>
- <ellipse cx="320" cy="60" rx="50" ry="40" style="fill:lightblue; stroke:blue; stroke-width:3;" />
- <ellipse cx="200" cy="60" rx="50" ry="30" style="fill:none; stroke:red; stroke-width:3;" />
- <ellipse cx="250" cy="60" rx="50" ry="30" style="fill:none; stroke:green; stroke-width:3; stroke-dasharray:10 5;" />
- <ellipse cx="390" cy="60" rx="50" ry="35" style="fill:none; stroke:orange; stroke-width:3; stroke-dasharray:10 5;" />
- <ellipse cx="440" cy="60" rx="50" ry="30" style="fill:none; stroke:cyan; stroke-width:3;" />
- </svg>
- </body>
- </html>

- <html>
- <body>
- <svg height="400" width="600">
- <ellipse cx="100" cy="80" rx="80" ry="40" style="fill:blue; stroke:blue; stroke-width:3; fill-opacity:0.3; stroke-dasharray:10 5;" />
- <ellipse cx="240" cy="80" rx="30" ry="70" style="fill:red; stroke:black; stroke-width:3; fill-opacity:0.5; stroke-opacity:0.5;" />
- <ellipse cx="380" cy="80" rx="80" ry="40" style="fill:green; stroke:green; stroke-width:3; stroke-dasharray:10 5; fill-opacity:0.7;" />
- </svg>
- </body>
- </html>

- <html>
- <body>
- <svg height="400" width="1000">
- <ellipse cx="180" cy="100" rx="150" ry="80" style="fill:blue; stroke:blue; stroke-width:3; fill-opacity:0.3; stroke-dasharray:10 5;" />
- <ellipse cx="155" cy="100" rx="120" ry="50" style="fill:red; stroke:black; stroke-width:3; fill-opacity:0.5; stroke-opacity:0.5;" />
- <ellipse cx="190" cy="100" rx="80" ry="40" style="fill:lime; stroke:blue; stroke-width:3; stroke-dasharray:10 5;" />
- <ellipse cx="200" cy="100" rx="50" ry="20" style="fill:orange; stroke:red; stroke-width:3; stroke-dasharray:10 5; fill-opacity:0.7;" />
- <ellipse cx="520" cy="100" rx="180" ry="70" style="fill:lime; stroke:blue; stroke-width:3; fill-opacity:0.3; stroke-dasharray:10 5;" />
- <ellipse cx="500" cy="100" rx="160" ry="60" style="fill:tomato; stroke:black; stroke-width:3; fill-opacity:0.5; stroke-opacity:0.5;" />
- <ellipse cx="480" cy="100" rx="140" ry="40" style="fill:cyan; stroke:black; stroke-width:3; fill-opacity:0.7;" />
- <ellipse cx="440" cy="100" rx="100" ry="30" style="fill:yellow; stroke:red; stroke-width:3; fill-opacity:0.7;" />
- </svg>
- </body>
- </html>

Want to read more.
Thank you, keep learning and sharing.

Prasanna MuraliPosted May 20, 2016, 11:25 AM
Nice one....
Gopi ChandPosted Aug 19, 2015, 6:46 AM
Thanks a lot everyone :)
Gowtham RajamanickamPosted Jul 27, 2015, 5:19 AM
good one
Sibeesh VenuPosted Jul 27, 2015, 12:42 AM
Nice Share. Thanks
Neeraj KumarPosted Jul 26, 2015, 4:56 PM
Good Work
Abhishek YadavPosted Jul 26, 2015, 1:57 PM
Wow!! Very nice!!!!
Harpreet SinghPosted Jul 26, 2015, 11:51 AM
7 examples..enough for me :)
RakeshPosted Jul 26, 2015, 10:43 AM
Good one sir
Ricky NguyenPosted Jul 26, 2015, 9:17 AM
Nice bro ^^
Pankaj Kumar ChoudharyPosted Jul 26, 2015, 7:12 AM
Nice One Sir............
Rajeesh MenothPosted Jul 25, 2015, 1:57 PM
Good One
Debasis SahaPosted Jul 21, 2015, 12:54 AM
Good One..
Gopi ChandPosted Jul 20, 2015, 9:53 AM
Glad to see the appreciation from you all :)
Sourabh SomaniPosted Jul 20, 2015, 9:18 AM
Good one :)
Sibeesh VenuPosted Jul 20, 2015, 9:08 AM
Good one :)
SharadPosted Jul 20, 2015, 6:39 AM
Good one..
Debendra DashPosted Jul 20, 2015, 6:36 AM
nice sir...
Nilesh JadavPosted Jul 20, 2015, 5:17 AM
Nice article sir