Absolute vs Relative SVG Path Commands

In SVG development, the d attribute of a <path> element defines the shape’s outline using a sequence of path commands and coordinates. The key difference between absolute and relative commands lies in how the coordinate values are calculated: absolute commands place points at exact coordinates within the SVG viewport, while relative commands place points relative to the current position of the virtual drawing pen. This article explains how both types operate, how command casing dictates behavior, and when to use each approach.

Case Sensitivity: The Core Rule

SVG path commands are case-sensitive. The letter case determines whether the coordinate values that follow are interpreted as absolute or relative:

The only exception is the close path command (Z or z), which performs the exact same function regardless of casing by drawing a straight line back to the start of the current sub-path.

How Absolute Commands Work

Absolute commands instruct the path renderer to move to an exact coordinate (x, y) in the SVG coordinate system, originating from the top-left corner (0, 0).

For example:

<path d="M 50 50 L 150 50 L 150 150 Z" fill="none" stroke="black" />

How Relative Commands Work

Relative commands treat the supplied coordinate values as offset values (dx, dy) added to the pen’s current position.

For example:

<path d="M 50 50 l 100 0 l 0 100 z" fill="none" stroke="black" />

Comparison of Common Path Commands

Command Absolute (Uppercase) Relative (Lowercase) Description
Move To M x,y m dx,dy Moves the pen without drawing.
Line To L x,y l dx,dy Draws a straight line to the destination.
Horizontal Line H x h dx Draws a horizontal line.
Vertical Line V y v dy Draws a vertical line.
Cubic Bézier C x1,y1 x2,y2 x,y c dx1,dy1 dx2,dy2 dx,dy Draws a cubic Bézier curve using two control points.
Quadratic Bézier Q x1,y1 x,y q dx1,dy1 dx,dy Draws a quadratic curve using one control point.
Arc A rx ry ... x y a rx ry ... dx dy Draws an elliptical arc to the target coordinate.

When to Use Absolute vs. Relative Commands