freecoding.school100% FREE · NO SIGNUP
Input HarborISSUE #20 of 46

svg · vector graphics in markup

FormaVSCaptain Invalid Input
Forma saysSVG draws vector graphics with markup — shapes are real elements you can style, animate, and click.

Where canvas is pixels, SVG is XML. <svg> contains shape elements — <rect>, <circle>, <line>, <path> — that live in the DOM. You can target them with CSS, attach event listeners, and they stay razor-sharp at any zoom.

Use SVG for icons, logos, charts, and anything that must scale crisply or respond to interaction. Use canvas when you're pushing thousands of pixels per frame (games). The viewBox defines the coordinate space.

Power-ups you unlock

Captain Invalid Input attacks — common mistakes

Boss battleDraw a circle and a rect in an SVG, then add a CSS :hover rule that changes the circle’s fill.

Example code

<!doctype html>
<html><head><meta charset="utf-8">
<style>circle:hover{fill:#8aff9d;cursor:pointer}</style>
</head>
<body style="background:#06040d;display:grid;place-items:center;height:100vh;margin:0">
  <svg width="300" height="200" viewBox="0 0 300 200">
    <rect x="20" y="40" width="100" height="100" fill="#b388ff" rx="8"/>
    <circle cx="210" cy="100" r="50" fill="#ffcf6b"/>
  </svg>
</body></html>
▶ Open the interactive comic issue
‹ Canvas · Text · Images · TransformsSvg · Paths · Gradients · Animation ›