</> Code Corner

HTML · HTML Graphics · Lesson 46

HTML SVG

Scalable Vector Graphics.

SVG stands for Scalable Vector Graphics. It defines vector-based graphics in XML format that do not lose quality when zoomed or resized.

Example

<svg width="300" height="120">
  <circle cx="60" cy="60" r="40" stroke="green" stroke-width="4" fill="yellow" />
  <rect x="120" y="20" width="80" height="80" style="fill:rgb(0,0,255);stroke-width:3;stroke:black" />
  <polygon points="250,10 290,110 210,110" style="fill:lime;" />
</svg>

SVG vs Canvas

SVG Canvas
Resolution independent Resolution dependent
Supports event handlers per shape No per-shape event handlers
Good for icons, logos, charts Good for games and pixel graphics

Keep reading “HTML SVG”

Sign up to read the full lesson, try every example in the live editor, and take the 5-question quiz.

Chat with us 👋