Path Syntax
The path element uses the d attribute with a series of commands:
<path d="M 10 10 L 90 90" />
Tip: Uppercase commands use absolute coordinates, lowercase use relative coordinates.
Path Commands Reference
Move To: M/m
Move the pen without drawing.
M x y // Move to (x, y)
m dx dy // Move relative
Starts a new subpath
Line To: L/l, H/h, V/v
Draw straight lines.
L x y // Line to (x, y)
H x // Horizontal line to x
V y // Vertical line to y
Cubic Bezier: C/c, S/s
Smooth curves with two control points.
C x1 y1, x2 y2, x y
S x2 y2, x y // Smooth (mirrors previous)
Quadratic Bezier: Q/q, T/t
Curves with one control point.
Q x1 y1, x y
T x y // Smooth continuation
Arc: A/a
Elliptical arc curves.
A rx ry rotation large-arc-flag sweep-flag x y
rx, ry: Radii of the ellipse
rotation: X-axis rotation in degrees
large-arc-flag: 0 = smaller arc, 1 = larger arc
sweep-flag: 0 = counter-clockwise, 1 = clockwise
x, y: End point
Close Path: Z/z
Draw a line back to the start.
M 10 10 L 90 10 L 50 90 Z // Triangle
Common Examples
Triangle
<path d="M 50 10 L 90 90 L 10 90 Z"/>
Heart
M 50 30
C 50 20, 30 0, 10 20
C -5 40, 50 80, 50 80
C 50 80, 105 40, 90 20
C 70 0, 50 20, 50 30 Z
Pro Tips
- Use relative commands for portable paths
- S and T commands for smooth curves
- Minimize commands with SVGO
- Use the Path Visualizer to debug
💡
SVG Paths Explained Simply
Imagine you're giving directions to someone holding a pen over a piece of paper. "Put your pen down at this spot. Now draw a line to that corner. Next, curve smoothly over to this point." That's exactly what an SVG path does—it's a sequence of instructions that tells the browser how to draw a shape, one command at a time.
The heart of every path is the d attribute, which contains these drawing instructions. Each instruction starts with a letter that describes what to do: M means "move to" (pick up the pen and place it somewhere new), L means "draw a line to," C means "draw a curve to," and Z means "close the shape by drawing back to the start." The numbers after each letter are the coordinates—where on the canvas that action should happen.
Curves might seem intimidating at first, but they follow a simple principle: control points. Think of them like magnets that pull the line toward them as it travels from one point to another. A Quadratic curve uses one magnet (control point), while a Cubic curve uses two, giving you more control over the shape. The curve doesn't pass through these control points—it just bends toward them, creating smooth, natural-looking arcs.
The beauty of SVG paths is that once you understand these basic commands, you can create virtually anything—from simple arrows and icons to intricate illustrations and animated graphics. Many design tools like Figma, Illustrator, and Inkscape generate path code automatically, so you can draw visually and then fine-tune the code when needed. Start with simple shapes using M, L, and Z, then gradually experiment with curves as you get comfortable.