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