
- HTML Tutorial
- HTML - Home
- HTML - Overview
- HTML - Basic Tags
- HTML - Elements
- HTML - Attributes
- HTML - Formatting
- HTML - Phrase Tags
- HTML - Meta Tags
- HTML - Comments
- HTML - Images
- HTML - Tables
- HTML - Lists
- HTML - Text Links
- HTML - Image Links
- HTML - Email Links
- HTML - Frames
- HTML - Iframes
- HTML - Blocks
- HTML - Backgrounds
- HTML - Colors
- HTML - Fonts
- HTML - Forms
- HTML - Embed Multimedia
- HTML - Marquees
- HTML - Header
- HTML - Style Sheet
- HTML - Javascript
- HTML - Layouts
- HTML References
- HTML - Tags Reference
- HTML - Attributes Reference
- HTML - Events Reference
- HTML - Fonts Reference
- HTML - ASCII Codes
- ASCII Table Lookup
- HTML - Color Names
- HTML - Entities
- HTML - Fonts Ref
- HTML - Events Ref
- MIME Media Types
- HTML - URL Encoding
- Language ISO Codes
- HTML - Character Encodings
- HTML - Deprecated Tags
How to draw shapes using SVG in HTML5?
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.
You can draw shapes like circle, rectangle, line, etc using SVG in HTML5 easily. Let’s see an example to draw a rectangle using SVG.
Example
You can try to run the following code to draw a rectangle in HTML5. The <rect> element will be used
<!DOCTYPE html> <html> <head> <style> #svgelem { position: relative; left: 10%; -webkit-transform: translateX(-20%); -ms-transform: translateX(-20%); transform: translateX(-20%); } </style> <title>SVG</title> </head> <body> <h2>HTML5 SVG Rectangle</h2> <svg id="svgelem" width="300" height="200" xmlns="http://www.w3.org/2000/svg"> <rect width="200" height="100" fill="green"/> </svg> </body> </html>
Output
- Related Articles
- How to draw SVG Logo in HTML5?
- How to draw grid using HTML5 and canvas or SVG?
- 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 a star in HTML5 SVG?
- How to draw sine waves with HTML5 SVG?
- How to draw an SVG file on an HTML5 canvas?
- How to use SVG images in HTML5?
- How to draw on scroll using JavaScript and SVG?
- How to draw a circle using an SVG tag in html?
- How to Draw Graphics using Canvas in HTML5?
- How to draw lines using HTML5 Canvas?
- How to draw custom shapes in JavaFX using the Path class?
- How to draw a hollow circle in SVG?

Advertisements