Graphics in HTML
HTML graphics capabilities allow the creation of both vector and raster visuals directly in the browser. Two main methods are available: <canvas> and <svg>. They serve different purposes and use different technical approaches.
<canvas> Element
The <canvas> element provides a blank drawing area on which you can use JavaScript to draw lines, shapes, images, or animations. All rendering is done programmatically, and the content is not preserved as DOM elements.
<svg> Element
SVG (Scalable Vector Graphics) uses an XML-based approach, where drawing elements like <rect> or <circle> are part of the DOM. It’s easy to scale, style with CSS, and make interactive with JavaScript.
Canvas vs SVG
Use <canvas> when fast, continuous updates are needed (e.g., games, real-time visualizations), and use <svg> for static, interactive, or vector-based graphics. SVG scales better and is easier to style with CSS.
Practical Use Cases
<svg> is commonly used for icons, logos, and charts. <canvas> is great for games, animations, or complex data visualizations. The choice depends on the specific use case.
✨ Ask Lara — your AI study partner
Unlock personalized learning support. Lara can explain lessons, summarize topics, and answer your study questions — available from the Go plan and above.
Lara helps you learn faster — exclusive to ReadyTools Go, Plus, and Max members.


