7.1 Absolute move to, line to, close path
Every path must begin with a moveto command.
The command letter is a capital M
followed by an x- and y-coordinate, separated by commas or whitespace.
This command
sets the current location of the "pen" that's drawing the outline.
Example 1
<svg width="200" height="150" viewBox="0 0 100 75" xmlns="http://www.w3.org/2000/svg"> <!-- segment --> <path d="M 10 10 L 90 10" style="stroke:red"/> <!-- perpendicular segments --> <path d="M 10 20 L 60 20 L 60 40" style="fill:none; stroke:orange"/> <!-- two thirty-degree angles --> <g style="stroke: green; fill: none;"> <path d="M 40 60 L 10 60 L 40 42.68 M 60 60 L 90 60, L 60 42.68" /> </g> </svg>
Step by step green path explanation
M 40 60
L 10 60
L 42 42.68
M 60 60
L 90 60
L 60 42.68
Example 2. Using closepath Z
<svg width="200" height="100" viewBox="0 0 200 100" xmlns="http://www.w3.org/2000/svg"> <!-- rectangle --> <path d="M 10 10 L 90 10 L 90 40 L 10 40 Z" style="stroke:red; fill:orange; fill-opacity:0.5"/> <!-- triangle --> <path d="M 10 60 L 90 60 L 90 90 Z" style="stroke:green; fill:green; fill-opacity:0.5"/> </svg>