
- 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 work with Scalable Vector Graphics (SVG) in HTML5?
SVG stands for Scalable Vector Graphics and it is a language for describing 2D-graphics and graphical applications in XML and the XML is then rendered by an SVG viewer.
SVG is mostly useful for vector type diagrams like Pie charts, Two-dimensional graphs in an X,Y coordinate system etc.
To work with Scalable Vector Graphics (SVG) in HTML5, embed SVG directly using <svg>...</svg> tags with the following syntax −
Syntax
<svg xmlns="http://www.w3.org/2000/svg"> ... </svg>
To draw a shape in HTML5 SVG, use
- <circle> element to draw a circle.
- <rect> element to draw a rectangle.
- <line> element to draw a line.
- <ellipse> element to draw and ellipse.
- <polygon> element to draw a polygon.
You can also add SVG to a web page using the <img>, <iframe>, <object> or <embed> tag. Let’s see how to add HTML5 SVG using the <svg> tag.
You can try to run the following code to learn how to work with SVG in HTML5. We will draw a circle here
Example
<!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 Circle</title> </head> <body> <h2>HTML5 SVG Circle</h2> <svg id="svgelem" height="200" xmlns="http://www.w3.org/2000/svg"> <circle id="greencircle" cx="60" cy="60" r="50" fill="green" /> </svg> </body> </html>
- Related Articles
- How to add Scalable Vector Graphics (SVG) to your Web Page?
- How to create SVG graphics using JavaScript?
- How to draw sine waves with HTML5 SVG?
- To “user-scalable=no” or not to “user-scalable=no” in HTML5
- How to use SVG images in HTML5?
- How to draw SVG Logo in HTML5?
- 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 shapes using SVG in HTML5?
- Make a star shape with HTML5 SVG
- How to use splash vector graphics on your Responsive Site?
- How to actually work with HTML5 Canvas camera/viewport?
- How to draw grid using HTML5 and canvas or SVG?

Advertisements