How to draw a star in HTML5 SVG?

SVG stands for Scalable Vector Graphics and is a language for describing 2D-graphics and graphical applications in XML and the XML is then rendered by an SVG viewer. Most of the web browsers can display SVG just like they can display PNG, GIF, and JPG.

To draw a polygon in HTML SVG, use the SVG element. The element creates a graphic containing at least three sides. For drawing a star in HTML5 SVG, you need to set the x and y coordinates properly for each corner.

Example

You can try to run the following code to learn how to draw a star in HTML5 SVG:


   
      
         
      HTML5 SVG Polygon Star
   
   
      

HTML5 SVG Star

                                   

Output

Updated on: 2021-12-16T09:34:31+05:30

9K+ Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements