Skip to main content
Albero Academy

SVG & Canvas

Two ways to draw graphics on a page.

Media & Embeds7 min

For graphics beyond images, HTML offers two approaches: SVG (vector graphics described in markup) and Canvas (a bitmap you draw on with JavaScript). They suit very different jobs.

SVG — scalable vector graphics

SVG is markup
<svg width="100" height="100" viewBox="0 0 100 100">
<circle cx="50" cy="50" r="40" fill="crimson" />
<text x="50" y="55" text-anchor="middle" fill="white">Hi</text>
</svg>

SVG vs Canvas

Key takeaways

  1. 01SVG describes vector graphics in markup — crisp at any size, in the DOM, CSS-styleable.
  2. 02Canvas is a bitmap you draw on with JavaScript — pixel-based.
  3. 03Use SVG for icons, logos, charts and interactive scalable graphics.
  4. 04Use Canvas for games, complex animation, or rendering many shapes fast.

Finished this chapter?

Mark it complete to track your progress through HTML.