Curriculum
Course: HTML Basic
Login

Curriculum

HTML Basic

HTML Introduction

0/1

HTML Editors

0/1

HTML Attributes

0/1

HTML Paragraphs

0/1

HTML Formatting

0/1

HTML Comments

0/1

HTML Favicon

0/1

HTML Page Title

0/1

HTML Iframes

0/1

HTML Java Script

0/1

HTML File Paths

0/1

HTML Symbols

0/1
Text lesson

Differences Between SVG and Canvas

SVG is a language for describing 2D graphics using XML, whereas Canvas draws 2D graphics on the fly using JavaScript.

Since SVG is XML-based, every element is accessible within the SVG DOM, allowing you to attach JavaScript event handlers to SVG graphics.

In SVG, each drawn shape is retained as an object. When the attributes of an SVG object are modified, the browser can automatically re-render the shape.

Canvas, on the other hand, renders graphics pixel by pixel. Once a graphic is drawn on a canvas, it is forgotten by the browser. To change its position, the entire scene, including any objects that were covered by the graphic, must be redrawn.

Comparison of SVG and Canvas

The table below highlights key differences between Canvas and SVG:

SVG

Canvas

·  Resolution independent

·  Supports event handlers

·  Excellent text rendering capabilities

·  Slow rendering for complex graphics

·  Not ideal for game applications

·  Resolution dependent

·  Does not support event handlers

·  Poor text rendering capabilities

·  Allows saving the resulting image as .png or .jpg

·  Well-suited for graphic-intensive games