SVG_and_Canvas
SVG_and_Canvas
SVG_and_Canvas
Canvas and SVG (Scalable Vector Graphics) are both popular technologies
used in web development for creating graphics and visualizations, but they
have different approaches and use cases.
Introduction to Canvas
It is a pixel-based drawing surface that is widely used for creating dynamic
and interactive content on the web.
Syntax:
Attributes:
• id: A unique identifier for the canvas.
• width: The width of the canvas.
• height: The height of the canvas.
• style: Additional styles for the canvas, such as borders or background color.
1|Page
Syntax:
Attributes:
● id: Provides a unique identifier for the SVG element.
● class: Assigns one or more class names to the SVG element.
● style: Specifies inline styles for the SVG element.
● fill: Specifies the fill color for the graphic element.
● stroke: Defines the color of the element's outline.
● stroke-width: Sets the width of the element's outline.
● viewBox: Defines the position and dimensions of the SVG content in
the user coordinate system.
● preserveAspectRatio: Specifies how the SVG content should be
scaled and positioned within the viewport.
2|Page