ADVERTISEMENT
Google AdSense Slot (headerLeaderboard)

Set your Publisher ID in src/config/ads.ts to display live ads.

SVG & HTML5 Canvas Tutorial• 7 min read

SVG Paths & Bezier Curves

The d attribute: MoveTo, LineTo, Arc, and Cubic/Quadratic Curves

The <path> element is the most versatile shape in SVG, capable of drawing arbitrary polygons, smooth splines, and complex UI icons through its d command string.

Key Path Commands in the d Attribute

M x y (Move To): Lifts the virtual pen and places it at (x, y) without drawing.

L x y (Line To): Draws a straight line to (x, y).

H x / V y: Draws horizontal or vertical straight lines.

C x1 y1, x2 y2, x y (Cubic Bezier): Draws a smooth curve guided by two control points (x1, y1) and (x2, y2).

Q x1 y1, x y (Quadratic Bezier): Draws a curve with a single control point.

Z (Close Path): Draws a straight line back to the initial M starting point, closing the contour.

Drawing a Checkmark Icon via SVG Path
<svg width="64" height="64" viewBox="0 0 24 24" fill="none" stroke="#04AA6D" stroke-width="2.5" stroke-linecap="round" stroke-linejoin="round">
  <!-- Checkmark Path: Move to (4, 12), Line to (9, 17), Line to (20, 6) -->
  <path d="M4 12 L9 17 L20 6" />
</svg>
SVG icon sets like Lucide and Heroicons are built entirely with concise path commands.
Pro Tip

Uppercase path letters (M, L, C) use absolute coordinates; lowercase letters (m, l, c) use coordinates relative to the previous point.

ADVERTISEMENT
Google AdSense Slot (inContentBanner)

Set your Publisher ID in src/config/ads.ts to display live ads.

Test Yourself With Exercise

+15 XP

Which SVG path command closes the current subpath by drawing a straight line back to the start coordinate?