HTML 5 SVG
HTML5 supports inline SVG.
What is SVG?
- SVG refers to Scalable Vector Graphics (Scalable Vector Graphics)
- SVG is used to define vector-based graphics for the web
- SVG uses XML format to define graphics
- SVG images will not lose their graphic quality when they are enlarged or changed in size
- SVG is the standard of the World Wide Web Consortium
Compared with other image formats (such as JPEG and GIF), the advantages of using SVG are:
- SVG images can be created and modified through a text editor
- SVG images can be searched, indexed, scripted or compressed
- SVG is scalable
- SVG images can be printed with high quality at any resolution
- SVG can be enlarged without degradation of image quality
Embed SVG directly into HTML page
In HTML5, you can embed SVG elements directly in HTML pages:
<!DOCTYPE html> <html> <head> <meta charset="utf-8"> <title>Novice Tutorial</title> </head> <body> <svg xmlns="http://www.w3.org/2000/svg" version="1.1" height="190"> <polygon points="100,10 40,180 190,60 10,60 160,180" style="fill:lime;stroke:purple;stroke-width:5;fill-rule:evenodd;"/> </svg> </body> </html>
Sorry, your browser does not support inline SVG.
To learn more about the SVG tutorial, please visit the SVG tutorial .
The difference between SVG and Canvas
SVG is a language that uses XML to describe 2D graphics.
In SVG, each drawn graphic is treated as an object. If the properties of the SVG object change, the browser can automatically reproduce the graphics.
Canvas is rendered pixel by pixel. In canvas, once the graphic is drawn, it will not continue to get the browser’s attention. If its position changes, then the entire scene needs to be redrawn, including any objects that may have been covered by graphics.
Comparison of Canvas and SVG
The following table lists some of the differences between canvas and SVG.