What is the difference between canvas and SVG in HTML5?

Canvas draws pixels using JavaScript. SVG describes shapes as XML elements.

PointCanvasSVG
TypeRaster (pixels)Vector (shapes)
Quality when zoomedBecomes blurryAlways sharp
Elements in the pageOne canvas element onlyEach shape is an element
CSS and events on shapesNoYes
Best forGames, charts with lots of data, image effectsIcons, logos, simple charts
<svg width="100" height="100">
  <circle cx="50" cy="50" r="40" fill="orange" />
</svg>
Output in the browser

See HTML5 Canvas.


Learn more about the similar topics:
Tutorials
No Content Found.
Exercises & Assignments
No Content Found.
Interview Questions & Answers
No Content Found.