SVG Cheatsheet
A concise technical SVG reference.
<svg width="128" height="128" viewBox="0 0 100 100" xmlns="http://www.w3.org/2000/svg"></svg>
<svg width="128" height="128" viewBox="-100 -100 200 200" xmlns="http://www.w3.org/2000/svg"></svg>
Rectangle <rect>
Parameters: Position, Size, optional corner radius
<rect x="10" y="10" width="50" height="50" />
<rect x="10" y="10" width="50" height="50" rx="20" ry="20" />
Circle <circle>
Parameters: center position, radius
<circle cx="25" cy="75" r="20"/>
Ellipse <ellipse>
Parameters: center position, radius
<ellipse cx="30" cy="30" rx="20" ry="25" />
Line <line>
Parameters: position 1, position 2
<line x1="10" y1="10" x2="80" y2="30" />
Polyline <polyline>
Parameter: points - as separators can be used space, comma, LF/EOL
<polyline points="10,10 20,10 30,30 10,50 10,30" />
equals <polyline points="10 10,20 10,30 30,10 50,10 30" />
Polygon <polygon>
Parameter: points - as separators can be used space, comma, LF/EOL
<polygon points="10,10 20,10 30,30 10,50 10,30" />
Path <path>
Parameter: draw commands (d
)
Path Commands
Commands use upper-case for absolute coordinates and lower-case for relative coordinates.
L x y
andl dx dy
for Line ToH x
h dx
horizonal lineV x
v dx
vertical lineZ
z
close pathQ x1 y1 x y
quadratic Bèzier curve - target point xy, curve control point x1y1T
symmetric quadratic curve transition - must followQ
orT
curve command - otherwise uses current point as first control point (resulting in a line)C x1 y1 x2 y2 x y
cubic Bèzier curve - withx y
target point and x1y1 x2y2 curve control pointsS
symmetric cubic curve transition - must followC
orS
curve command - otherwise uses current point as first control pointA
arc -A rx ry x-axis-rotation large-arc-flag sweep-flag x y
- large-arc-flag: the arc should be greater than or less than 180 degrees (circle draw direction)
Text <text>
Parameters: Position
Inline Span <tspan>
Text Path <textPath>
Group <g>
Groups elements to apply properties to all elements of the group at once (like styles and transformation).
Raster Image <image>
<image href="" />
Clipping <clipPath>
and Masking <mask>
Filter <filter>
CSS filters work on SVG.
SVG defines a filter element too:
Font <font>
⚠️ Web-Deprecated - see note on https://developer.mozilla.org/en-US/docs/Web/SVG/Tutorial/SVG_fonts
<use>
<use>
deep-clones into a non-DOM-exposed element (into a shadow DOM).