SVG: The Scalable Vector Graphics (SVG) is an XML-based image format that is used to define two-dimensional vector-based graphics for the web. Unlike raster image (Ex .jpg, .gif, .png, etc.), a vector image can be scaled up or down to any extent without losing the image quality.
An SVG image is drawn out using a series of statements that follow the XML schema — that means SVG images can be created and edited with any text editor, such as Notepad. There are several other advantages of using SVG over other image formats like JPEG, GIF, PNG, etc.
Difference between SVG and HTML5 Canvas:
|Vector based (composed of shapes)||Raster based (composed of pixel)|
|SVG has better scalability. So it can be printed with high quality at any resolution.||Canvas has poor scalability. Hence it is not suitable for printing on higher resolution.|
|SVG gives better performance with smaller number of objects or larger surface.||Canvas gives better performance with smaller surface or larger number of objects.|
|SVG can be modified through script and CSS.||Canvas can be modified through script only.|
|Multiple graphical elements, which become the part of the page’s DOM tree.||Single element similar to <img> in behavior. Canvas diagram can be saved to PNG or JPG format.|
- HTML | SVG-Basics
- HTML | SVG pattern
- HTML SVG <rect>
- HTML SVG <text>
- HTML SVG <Line>
- HTML SVG <filter>
- HTML SVG <Ellipse>
- HTML SVG Gradients
- How to set the SVG background color ?
- SVG viewBox Attribute
- How to remove SVG content?
- How to Create Custom Shape Button using SVG ?
- How to change SVG color ?
- How to use SVG Patterns as the background ?
- How to use z-index in svg elements ?
- SVG Path Element
- SVG Polyline element
- SVG Stroke Properties
- SVG defs Element
- SVG polygon Element
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to firstname.lastname@example.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.