CSS techniques

SVG path commands explained: M, L, C, Q, A and Z

What every letter in an SVG path's d attribute means: move, line, cubic and quadratic curves, arcs and close path, absolute versus relative coordinates, and how the arc flags work.

An SVG path is a list of drawing commands in its d attribute. M moves the pen, L draws a straight line, H and V draw horizontal and vertical lines, C and S draw cubic Bézier curves, Q and T draw quadratic curves, A draws an elliptical arc and Z closes the shape. Uppercase letters use absolute coordinates; lowercase letters are relative to the previous point. The SVG path editor shows every point and handle of a path so you can see how it is built and drag it into shape.

Key takeaways

  • Every path starts with M (move to).
  • Uppercase = absolute coordinates, lowercase = relative to the current point.
  • Cubic curves (C) have two control handles; quadratic curves (Q) have one.
  • Arcs (A) take seven values, two of which are 0/1 flags that choose which of four possible arcs to draw.

What does each SVG path command do?

CommandNameParametersDraws
M / mMove tox yLifts the pen and moves it, without drawing
L / lLine tox yA straight line
H / hHorizontal linexA horizontal line
V / vVertical lineyA vertical line
C / cCubic Bézierx1 y1 x2 y2 x yA curve with two control points
S / sSmooth cubicx2 y2 x yA cubic curve whose first handle mirrors the previous one
Q / qQuadratic Bézierx1 y1 x yA curve with one control point
T / tSmooth quadraticx yA quadratic curve with a mirrored control point
A / aArcrx ry rotation large-arc sweep x yPart of an ellipse
Z / zClose pathnoneA straight line back to the start of the subpath

Absolute or relative coordinates?

L 50 20 draws a line to the point (50, 20) on the canvas. l 50 20 draws a line 50 units right and 20 units down from wherever the pen is now. Both describe the same kinds of shape; relative commands are usually shorter because the numbers are smaller, which is why optimisers like SVGO often convert to them. Absolute commands are easier to read and edit by hand.

<!-- The same square, two ways -->
<path d="M 10 10 L 90 10 L 90 90 L 10 90 Z" />
<path d="M10 10h80v80H10z" />

The second version also shows how compact path data gets: commands can drop spaces where a letter or minus sign separates the numbers, and a command letter can be left out when it repeats.

How do Bézier curves work?

A Bézier curve starts at the current point and ends at its final x y pair. The control points in between don’t sit on the curve; they pull it towards themselves, like magnets. In design apps these are the handles you drag.

<!-- A cubic curve: start (10,80), handles (40,10) and (65,10), end (95,80) -->
<path d="M 10 80 C 40 10, 65 10, 95 80" />

<!-- Continue smoothly: S mirrors the last handle automatically -->
<path d="M 10 80 C 40 10, 65 10, 95 80 S 150 150, 180 80" />

Quadratic curves (Q) have one shared handle, so they are simpler but less flexible. Most icons and logos exported from Figma or Illustrator use cubic curves, because that is what the pen tool creates.

How does the arc command work?

Arcs are the command people find hardest. A rx ry rotation large-arc-flag sweep-flag x y draws part of an ellipse from the current point to (x, y). Between two points there are usually four ellipse arcs of a given size that could connect them, and the two flags pick one:

  • large-arc-flag: 1 takes the long way round (more than 180°), 0 the short way.
  • sweep-flag: 1 draws clockwise, 0 anticlockwise.
  • rotation tilts the ellipse, in degrees. For circles it makes no difference.
<!-- A semicircle from (10,50) to (90,50), radius 40, over the top -->
<path d="M 10 50 A 40 40 0 0 1 90 50" />

Arc radius: If the radius is too small to reach the end point, browsers scale it up automatically until the arc fits, rather than failing. That is useful, but it can make a tweaked arc look unexpectedly round.

Why would you edit path data by hand?

  • Fix an icon that is slightly off the grid, so it looks crisp at small sizes.
  • Find a stray point that makes a corner look lumpy.
  • Simplify a shape by removing points a design tool added.
  • Prepare a path for animation, for example morphing two shapes, which needs matching numbers of points.
  • Understand a logo before rebuilding or animating it.

Reading a long d string is almost impossible, which is why a visualiser helps. In the SVG path editor, blue squares are points on the path and pink circles are control handles. Drag either to reshape the path, then copy it back out as absolute or relative commands, or as a complete SVG with a fitted viewBox.

Making path data smaller

Path data is usually the biggest part of an icon file. Rounding coordinates to one decimal place, using relative commands and removing redundant points can shrink it a lot without visible change. The SVG optimiser does this with SVGO, and our guide to optimising SVG files explains which settings are safe. If you are starting from a PNG, tracing it to SVG creates the paths for you.

Last checked: October 2026.

Sources: MDN: Paths tutorial, MDN: d attribute, W3C SVG 2: Paths.