
- Javascript Basics Tutorial
- Javascript - Home
- Javascript - Overview
- Javascript - Syntax
- Javascript - Enabling
- Javascript - Placement
- Javascript - Variables
- Javascript - Operators
- Javascript - If...Else
- Javascript - Switch Case
- Javascript - While Loop
- Javascript - For Loop
- Javascript - For...in
- Javascript - Loop Control
- Javascript - Functions
- Javascript - Events
- Javascript - Cookies
- Javascript - Page Redirect
- Javascript - Dialog Boxes
- Javascript - Void Keyword
- Javascript - Page Printing
- JavaScript Objects
- Javascript - Objects
- Javascript - Number
- Javascript - Boolean
- Javascript - Strings
- Javascript - Arrays
- Javascript - Date
- Javascript - Math
- Javascript - RegExp
- Javascript - HTML DOM
- JavaScript Advanced
- Javascript - Error Handling
- Javascript - Validations
- Javascript - Animation
- Javascript - Multimedia
- Javascript - Debugging
- Javascript - Image Map
- Javascript - Browsers
- JavaScript Useful Resources
- Javascript - Questions And Answers
- Javascript - Quick Guide
- Javascript - Functions
- Javascript - Resources
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 <polygon> element. The <polygon> 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:
<!DOCTYPE html> <html> <head> <style> #svgelem { position: relative; left: 10%; -webkit-transform: translateX(-20%); -ms-transform: translateX(-20%); transform: translateX(-20%); } </style> <title>HTML5 SVG Polygon Star</title> </head> <body> <h2>HTML5 SVG Star</h2> <svg id = "svgelem" width = "300" height = "300" xmlns = "http://www.w3.org/2000/svg"> <polygon points="100,10 40,180 190,60 10,60 160,180" fill="blue"/> </svg> </body> </html>
Output
- Related Articles
- How to draw a rectangle in HTML5 SVG?
- How to draw a polygon in HTML5 SVG?
- How to draw a polyline in HTML5 SVG?
- How to draw SVG Logo in HTML5?
- How to draw shapes using SVG in HTML5?
- Make a star shape with HTML5 SVG
- How to draw sine waves with HTML5 SVG?
- How to draw a star by using canvas HTML5?
- How to draw grid using HTML5 and canvas or SVG?
- How to draw an SVG file on an HTML5 canvas?
- How to use SVG images in HTML5?
- How to draw a hollow circle in SVG?
- How to work with Scalable Vector Graphics (SVG) in HTML5?
- How to draw a circle using an SVG tag in html?
- How to draw star shape in android?

Advertisements