• +91 9723535972
  • info@interviewmaterial.com

HTML Interview Questions and Answers

Related Subjects

Question - Explain the difference between Canvas and SVG elements.

Answer -

Following are the various differences between and elements:

1. API Animation
Canvas has no provision for API animation. SVG, on the contrary, is capable of API animation.

2. Change Accommodation
Each drawn shape in SVG is remembered as an object by the web browser. If the attributes pertaining to an SVG object are changed, the browser automatically re-renders the shape.
The web browser forgets once the graphic is drawn in Canvas. If there is a change in the position of a Canvas graphic, the complete scene requires redrawing. While modification in Canvas is only allowed through the script, SVG supports modification via script as well as CSS.

3. Definition
SVG stands for Scalable Vector Graphics. It features many methods for drawing bitmap images, boxes, circles, paths, and text.
SVG is a language for describing 2D graphics, where the element is a container for SVG graphics. Canvas allows users to draw 2D graphics on the fly using J.S.

4. Dependency
SVG doesn't depend on the resolution, while Canvas completely depends on the same.

5. How is it handled?
SVG is XML-based, meaning that each element is available within the SVG DOM. For an element, you can attach several J.S. event handlers. Canvas is rendered pixel by pixel, i.e., it is pixel-based. There is no support for event handlers in elements.

6. Ideal for
While Canvas is suitable for small rendering areas and games graphics, SVG is the best option for large rendering areas and printing with high-quality at any resolution.

7. Scalability
Canvas has poor scalability. SVG, however, has better scalability.

Comment(S)

Show all Coment

Leave a Comment




NCERT Solutions

 

Share your email for latest updates

Name:
Email:

Our partners