SVG Visual Cheat Sheet

Basic Examples

Primitive Code Show
Images
image
xlink:href, x, y, width, height
 
<svg xmlns="http://www.w3.org/2000/svg" version="1.1" width="300px" height="200px">
  <image xlink:href="Venus_de_Milo_Louvre.jpg" x="110" y="1" width="80" height="198" />
</svg>
Text
text
x, y
 
<svg xmlns="http://www.w3.org/2000/svg" version="1.1" width="300px" height="200px">
  <text x="60" y="150">Hello World</text>
</svg>
Hello World
stroke, stroke-width, fill (text)
 
<svg xmlns="http://www.w3.org/2000/svg" version="1.1" width="300px" height="200px">
  <text x="110" y="30">Simplest Text</text>
  <text x="110" y="70" stroke="black">Outlined/filled</text>
  <text x="110" y="110" stroke="black" stroke-width="0.5" fill="none">Outlined only</text>
</svg>
Simplest Text Outlined/filled Outlined only
color stroke (text)
 
<svg xmlns="http://www.w3.org/2000/svg" version="1.1" width="300px" height="210px">
  <text x="110" y="30" font-size="1.1em" stroke="red">stroke="red"</text>
  <text x="110" y="60" font-size="1.1em" stroke="orange">stroke="orange"</text>
  <text x="110" y="90" font-size="1.1em" stroke="yellow">stroke="yellow"</text>
  <text x="110" y="120" font-size="1.1em" stroke="green">stroke="green"</text>
  <text x="110" y="150" font-size="1.1em" stroke="blue">stroke="blue"</text>
  <text x="110" y="180" font-size="1.1em" stroke="darkblue">stroke="darkblue"</text>
  <text x="110" y="210" font-size="1.1em" stroke="violet">stroke="violet"</text>
</svg>
stroke="red" stroke="orange" stroke="yellow" stroke="green" stroke="blue" stroke="darkblue" stroke="violet"
color fill (text)
 
<svg xmlns="http://www.w3.org/2000/svg" version="1.1" width="300px" height="210px">
  <text x="110" y="30" font-size="1.1em" fill="red">fill="red"</text>
  <text x="110" y="60" font-size="1.1em" fill="orange">fill="orange"</text>
  <text x="110" y="90" font-size="1.1em" fill="yellow">fill="yellow"</text>
  <text x="110" y="120" font-size="1.1em" fill="green">fill="green"</text>
  <text x="110" y="150" font-size="1.1em" fill="blue">fill="blue"</text>
  <text x="110" y="180" font-size="1.1em" fill="darkblue">fill="darkblue"</text>
  <text x="110" y="210" font-size="1.1em" fill="violet">fill="violet"</text>
</svg>
fill="red" fill="orange" fill="yellow" fill="green" fill="blue" fill="darkblue" fill="violet"
font-size
 
<svg xmlns="http://www.w3.org/2000/svg" version="1.1" width="300px" height="500px">
  <text x="60" y="30">no font-size</text>
  <text x="60" y="60" font-size="10">font-size="10"</text>
  <text x="60" y="90" font-size="12">font-size="12"</text>
  <text x="60" y="120" font-size="14">font-size="14"</text>
  <text x="60" y="150" font-size="10pt">font-size="10pt"</text>
  <text x="60" y="180" font-size="12pt">font-size="12pt"</text>
  <text x="60" y="210" font-size="14pt">font-size="14pt"</text>
  <text x="60" y="240" font-size="10px">font-size="10px"</text>
  <text x="60" y="270" font-size="12px">font-size="12px"</text>
  <text x="60" y="300" font-size="14px">font-size="14px"</text>
  <text x="60" y="330" font-size="0.8em">font-size="0.8em"</text>
  <text x="60" y="360" font-size="1em">font-size="1em"</text>
  <text x="60" y="390" font-size="1.2em">font-size="1.2em"</text>
  <text x="60" y="420" font-size="80%">font-size="80%"</text>
  <text x="60" y="450" font-size="100%">font-size="100%"</text>
  <text x="60" y="480" font-size="120%">font-size="120%"</text>
</svg>
no font-size font-size="10" font-size="12" font-size="14" font-size="10pt" font-size="12pt" font-size="14pt" font-size="10px" font-size="12px" font-size="14px" font-size="0.8em" font-size="1em" font-size="1.2em" font-size="80%" font-size="100%" font-size="120%"
font-weight
 
<svg xmlns="http://www.w3.org/2000/svg" version="1.1" width="300px" height="300px">
  <text x="60" y="20" font-size="1.1em">normal</text>
  <text x="60" y="40" font-size="1.1em" font-weight="normal">font-weight="normal"</text>
  <text x="60" y="60" font-size="1.1em" font-weight="bold">font-weight="bold"</text>
  <text x="60" y="80" font-size="1.1em" font-weight="bolder">font-weight="bolder"</text>
  <text x="60" y="100" font-size="1.1em" font-weight="lighter">font-weight="lighter"</text>
  <text x="60" y="120" font-size="1.1em" font-weight="100">font-weight="100"</text>
  <text x="60" y="140" font-size="1.1em" font-weight="200">font-weight="200"</text>
  <text x="60" y="160" font-size="1.1em" font-weight="300">font-weight="300"</text>
  <text x="60" y="180" font-size="1.1em" font-weight="400">font-weight="400"</text>
  <text x="60" y="200" font-size="1.1em" font-weight="500">font-weight="500"</text>
  <text x="60" y="220" font-size="1.1em" font-weight="600">font-weight="600"</text>
  <text x="60" y="240" font-size="1.1em" font-weight="700">font-weight="700"</text>
  <text x="60" y="260" font-size="1.1em" font-weight="800">font-weight="800"</text>
  <text x="60" y="280" font-size="1.1em" font-weight="900">font-weight="900"</text>
</svg>
normal font-weight="normal" font-weight="bold" font-weight="bolder" font-weight="lighter" font-weight="100" font-weight="200" font-weight="300" font-weight="400" font-weight="500" font-weight="600" font-weight="700" font-weight="800" font-weight="900"
font-family
 
<svg xmlns="http://www.w3.org/2000/svg" version="1.1" width="300px" height="200px">
  <text x="60" y="20" font-size="1.1em">no font-family</text>
  <text x="60" y="40" font-size="1.1em" font-family="serif">font-family="serif"</text>
  <text x="60" y="60" font-size="1.1em" font-family="sans-serif">font-family="sans-serif"</text>
  <text x="60" y="80" font-size="1.1em" font-family="cursive">font-family="cursive"</text>
  <text x="60" y="100" font-size="1.1em" font-family="fantasy">font-family="fantasy"</text>
  <text x="60" y="120" font-size="1.1em" font-family="monospace">font-family="monospace"</text>
  <text x="60" y="140" font-size="1.1em" font-family="georgia">font-family="georgia"</text>
  <text x="60" y="160" font-size="1.1em" font-family="impact">font-family="impact"</text>
  <text x="60" y="180" font-size="1.1em" font-family="times">font-family="times"</text>
</svg>
no font-family font-family="serif" font-family="sans-serif" font-family="cursive" font-family="fantasy" font-family="monospace" font-family="georgia" font-family="impact" font-family="times"
font-style
 
<svg xmlns="http://www.w3.org/2000/svg" version="1.1" width="300px" height="200px">
  <text x="60" y="20" font-size="1.1em">no font-style</text>
  <text x="60" y="40" font-size="1.1em" font-style="normal">font-style="normal"</text>
  <text x="60" y="60" font-size="1.1em" font-style="italic">font-style="italic"</text>
  <text x="60" y="80" font-size="1.1em" font-style="oblique">font-style="oblique"</text>
</svg>
no font-style font-style="normal" font-style="italic" font-style="oblique"
text-decoration
 
<svg xmlns="http://www.w3.org/2000/svg" version="1.1" width="300px" height="200px">
  <text x="60" y="20" font-size="1.1em">no text-decoration</text>
  <text x="60" y="50" font-size="1.1em" text-decoration="none">text-decoration="none"</text>
  <text x="60" y="80" font-size="1.1em" text-decoration="underline">text-decoration="underline"</text>
  <text x="60" y="110" font-size="1.1em" text-decoration="overline">text-decoration="overline"</text>
  <text x="60" y="140" font-size="1.1em" text-decoration="line-through">text-decoration="line-through"</text>
  <text x="60" y="170" font-size="1.1em" text-decoration="blink">text-decoration="blink"</text>
</svg>
no text-decoration text-decoration="none" text-decoration="underline" text-decoration="overline" text-decoration="line-through" text-decoration="blink"
word-spacing
 
<svg xmlns="http://www.w3.org/2000/svg" version="1.1" width="300px" height="200px">
  <text x="60" y="20" font-size="1.1em">no word spacing</text>
  <text x="60" y="40" font-size="1.1em" word-spacing="10">word spacing 10</text>
  <text x="60" y="60" font-size="1.1em" word-spacing="20">word spacing 20</text>
  <text x="60" y="80" font-size="1.1em" word-spacing="10pt">word spacing 10pt</text>
  <text x="60" y="100" font-size="1.1em" word-spacing="20pt">word spacing 20pt</text>
  <text x="60" y="120" font-size="1.1em" word-spacing="10px">word spacing 10px</text>
  <text x="60" y="140" font-size="1.1em" word-spacing="20px">word spacing 20px</text>
  <text x="60" y="160" font-size="1.1em" word-spacing="1em">word spacing 1em</text>
  <text x="60" y="180" font-size="1.1em" word-spacing="2em">word spacing 2em</text>
  <text x="60" y="200" font-size="1.1em" word-spacing="50%">word spacing 50%</text>
  <text x="60" y="220" font-size="1.1em" word-spacing="200%">word spacing 200%</text>
</svg>
no word spacing word spacing 10 word spacing 20 word spacing 10pt word spacing 20pt word spacing 10px word spacing 20px word spacing 1em word spacing 2em word spacing 50% word spacing 200%
letter-spacing
 
<svg xmlns="http://www.w3.org/2000/svg" version="1.1" width="300px" height="240px">
  <text x="5" y="20" font-size="1.1em">no letter spacing</text>
  <text x="5" y="40" font-size="1.1em" letter-spacing="2">letter spacing 2</text>
  <text x="5" y="60" font-size="1.1em" letter-spacing="5">letter spacing 5</text>
  <text x="5" y="80" font-size="1.1em" letter-spacing="2pt">letter spacing 2pt</text>
  <text x="5" y="100" font-size="1.1em" letter-spacing="5pt">letter spacing 5pt</text>
  <text x="5" y="120" font-size="1.1em" letter-spacing="2px">letter spacing 2px</text>
  <text x="5" y="140" font-size="1.1em" letter-spacing="5px">letter spacing 5px</text>
  <text x="5" y="160" font-size="1.1em" letter-spacing="0.2em">letter spacing 0.2em</text>
  <text x="5" y="180" font-size="1.1em" letter-spacing="0.5em">letter spacing 0.5em</text>
  <text x="5" y="200" font-size="1.1em" letter-spacing="50%">letter spacing 50%</text>
  <text x="5" y="220" font-size="1.1em" letter-spacing="200%">letter spacing 200%</text>
</svg>
no letter spacing letter spacing 2 letter spacing 5 letter spacing 2pt letter spacing 5pt letter spacing 2px letter spacing 5px letter spacing 0.2em letter spacing 0.5em letter spacing 50% letter spacing 200%
text-anchor
 
<svg xmlns="http://www.w3.org/2000/svg" version="1.1" width="300px" height="200px">
  <text x="150" y="30" font-size="1.1em" text-anchor="start">text-anchor="start"</text>
  <text x="150" y="60" font-size="1.1em" text-anchor="middle">text-anchor="middle"</text>
  <text x="150" y="90" font-size="1.1em" text-anchor="end">text-anchor="end"</text>
</svg>
text-anchor="start" text-anchor="middle" text-anchor="end"
tspan
 
<svg xmlns="http://www.w3.org/2000/svg" version="1.1" width="300px" height="200px">
  <text x="10" y="30" style="font-size:12pt;">
    Switch among
    <tspan font-style="italic">italic</tspan>, normal,
    and <tspan font-weight="bold">bold</tspan> text.
  </text>
</svg>
Switch among italic, normal, and bold text.
dy (text)
 
<svg xmlns="http://www.w3.org/2000/svg" version="1.1" width="300px" height="200px">
  <text x="10" y="30" style="font-size:12pt;">
    F <tspan dy="4">a</tspan> <tspan dy="8">l</tspan> <tspan dy="12">l</tspan>
  </text>
</svg>
F a l l
baseline-shift
 
<svg xmlns="http://www.w3.org/2000/svg" version="1.1" width="300px" height="200px">
  <text x="20" y="50" font-size="1.1em">
    C<tspan baseline-shift="sub">12</tspan>
    H<tspan baseline-shift="sub">22</tspan>
    O<tspan baseline-shift="sub">11</tspan> (Sugar)
  </text>
  <text x="20" y="100" font-size="1.1em">
    6.02 x 10<tspan baseline-shift="super">23</tspan> (Avogadro's number)
  </text>
  <text x="20" y="150" font-size="1.1em">
    10<tspan baseline-shift="super">10<tspan baseline-shift="super">2</tspan></tspan> (Googol)
  </text>
</svg>
C12 H22 O11 (Sugar) 6.02 x 1023 (Avogadro's number) 10102 (Googol)
textLength and lengthAdjust
spacing, spacingAndGlyphs
 
<svg xmlns="http://www.w3.org/2000/svg" version="1.1" width="300px" height="200px">
  <text x="20" y="50" font-size="1.1em">
  <text x="20" y="30" font-size="1.1em" textLength="200" lengthAdjust="spacing">Two words</text>
  <text x="20" y="60" font-size="1.1em" textLength="200" lengthAdjust="spacingAndGlyphs">Two words</text>
  <text x="20" y="90" font-size="1.1em">Two words <tspan style="font-size: 10pt;">(normal length)</tspan></text>
  <text x="20" y="120" font-size="1.1em" textLength="80" lengthAdjust="spacing">Two words</text>
  <text x="20" y="150" font-size="1.1em" textLength="80" lengthAdjust="spacingAndGlyphs">Two words</text>
</svg>
Two words Two words Two words (normal length) Two words Two words
direction
ltr, rtl
unicode-bidi
normal, embed, bidi-override
 
<svg xmlns="http://www.w3.org/2000/svg" version="1.1" width="300px" height="200px">
  <text x="20" y="40" direction="rtl">direction="rtl"</text>
  <text x="20" y="60" direction="ltr">direction="ltr"</text>
  <text x="20" y="80" direction="rtl" unicode-bidi="normal">direction="rtl" unicode-bidi="normal"</text>
  <text x="20" y="100" direction="ltr" unicode-bidi="normal">direction="ltr" unicode-bidi="normal"</text>
  <text x="20" y="120" direction="rtl" unicode-bidi="embed">direction="rtl" unicode-bidi="embed"</text>
  <text x="20" y="140" direction="ltr" unicode-bidi="embed">direction="ltr" unicode-bidi="embed"</text>
  <text x="20" y="160" direction="rtl" unicode-bidi="bidi-override">direction="rtl" unicode-bidi="bidi-override"</text>
  <text x="20" y="180" direction="ltr" unicode-bidi="bidi-override">direction="ltr" unicode-bidi="bidi-override"</text>
</svg>
direction="rtl" direction="ltr" direction="rtl" unicode-bidi="normal" direction="ltr" unicode-bidi="normal" direction="rtl" unicode-bidi="embed" direction="ltr" unicode-bidi="embed" direction="rtl" unicode-bidi="bidi-override" direction="ltr" unicode-bidi="bidi-override"
unicode
 
<svg xmlns="http://www.w3.org/2000/svg" version="1.1" width="300px" height="200px">
  <text x="10" y="30">Greek: </text>
  <text x="100" y="30">αβγδε</text>
  <text x="10" y="50">Russian:</text>
  <text x="100" y="50">абвгд</text>
  <text x="10" y="70">Hebrew:</text>
  <text x="100" y="70">אבגדה (written right to left)</text>
  <text x="10" y="90">Arabic:</text>
  <text x="100" y="90">ابةت (written right to left)</text>
</svg>
Greek: αβγδε Russian: абвгд Hebrew: אבגדה (written right to left) Arabic: ابةت (written right to left)
writing-mode
lr-tb, rl-tb, tb-rl, lr, rl, tb
 
<svg xmlns="http://www.w3.org/2000/svg" version="1.1" width="300px" height="300px">
  <text x="60" y="20" font-size="1.1em" writing-mode="lr">writing-mode: lr</text>
  <text x="80" y="40" font-size="1.1em" writing-mode="rl">writing-mode: rl</text>
  <text x="100" y="60" font-size="1.1em" writing-mode="lr-tb">writing-mode: lr-tb</text>
  <text x="120" y="80" font-size="1.1em" writing-mode="rl-tb">writing-mode: rl-tb</text>
  <text x="140" y="100" font-size="1.1em" writing-mode="tb">writing-mode: tb</text>
  <text x="160" y="120" font-size="1.1em" writing-mode="tb-rl">writing-mode: tb-rl</text>
</svg>
writing-mode: lr writing-mode: rl writing-mode: lr-tb writing-mode: rl-tb writing-mode: tb writing-mode: tb-rl
Lines
line
 
<svg xmlns="http://www.w3.org/2000/svg" version="1.1" width="300px" height="200px">
  <line x1="10" y1="30" x2="230" y2="110" stroke="green" stroke-width="5" />
</svg>
<svg xmlns="http://www.w3.org/2000/svg" version="1.1" width="300px" height="200px">
  <line x1="20" y1="180" x2="250" y2="10" stroke="red" stroke-width="1" />
</svg>
vertical line
 
see also: path
 
<svg xmlns="http://www.w3.org/2000/svg" version="1.1" width="300px" height="200px">
  <line x1="150" y1="20" x2="150" y2="180" stroke="blue" stroke-width="10" />
</svg>
horizontal line
 
see also: path
 
<svg xmlns="http://www.w3.org/2000/svg" version="1.1" width="300px" height="200px">
  <line x1="20" y1="100" x2="280" y2="100" stroke="orange" stroke-width="2" />
</svg>
stroke-width
 
<svg xmlns="http://www.w3.org/2000/svg" version="1.1" width="300px" height="200px">
  <line x1="40" y1="10" x2="10" y2="190" stroke="midnightblue" />
  <line x1="70" y1="10" x2="40" y2="190" stroke="midnightblue" stroke-width="0" />
  <line x1="100" y1="10" x2="70" y2="190" stroke="midnightblue" stroke-width="1" />
  <line x1="130" y1="10" x2="100" y2="190" stroke="midnightblue" stroke-width="2" />
  <line x1="160" y1="10" x2="130" y2="190" stroke="midnightblue" stroke-width="4" />
  <line x1="190" y1="10" x2="160" y2="190" stroke="midnightblue" stroke-width="6" />
  <line x1="220" y1="10" x2="190" y2="190" stroke="midnightblue" stroke-width="10" />
  <line x1="250" y1="10" x2="220" y2="190" stroke="midnightblue" stroke-width="12" />
  <line x1="280" y1="10" x2="250" y2="190" stroke="midnightblue" stroke-width="14" />
</svg>
stroke-opacity
 
<svg xmlns="http://www.w3.org/2000/svg" version="1.1" width="300px" height="200px">
  <line x1="150" y1="0" x2="150" y2="200" stroke="red" stroke-width="10" />
  <line x1="20" y1="10" x2="280" y2="10" stroke="violet" stroke-width="10" stroke-opacity="0.0" />
  <line x1="20" y1="30" x2="280" y2="30" stroke="violet" stroke-width="10" stroke-opacity="0.1" />
  <line x1="20" y1="50" x2="280" y2="50" stroke="violet" stroke-width="10" stroke-opacity="0.2" />
  <line x1="20" y1="70" x2="280" y2="70" stroke="violet" stroke-width="10" stroke-opacity="0.3" />
  <line x1="20" y1="90" x2="280" y2="90" stroke="violet" stroke-width="10" stroke-opacity="0.5" />
  <line x1="20" y1="110" x2="280" y2="110" stroke="violet" stroke-width="10" stroke-opacity="0.6" />
  <line x1="20" y1="130" x2="280" y2="130" stroke="violet" stroke-width="10" stroke-opacity="0.7" />
  <line x1="20" y1="150" x2="280" y2="150" stroke="violet" stroke-width="10" stroke-opacity="0.8" />
  <line x1="20" y1="170" x2="280" y2="170" stroke="violet" stroke-width="10" stroke-opacity="0.9" />
  <line x1="20" y1="190" x2="280" y2="190" stroke="violet" stroke-width="10" stroke-opacity="1.0" />
</svg>
stroke-dasharray
 
<svg xmlns="http://www.w3.org/2000/svg" version="1.1" width="300px" height="200px">
  <line x1="20" y1="10" x2="280" y2="10" stroke="grey" stroke-width="2" stroke-dasharray="5, 5" />
  <line x1="20" y1="30" x2="280" y2="30" stroke="grey" stroke-width="2" stroke-dasharray="5, 10" />
  <line x1="20" y1="50" x2="280" y2="50" stroke="grey" stroke-width="2" stroke-dasharray="10, 5" />
  <line x1="20" y1="70" x2="280" y2="70" stroke="grey" stroke-width="2" stroke-dasharray="5, 1" />
  <line x1="20" y1="90" x2="280" y2="90" stroke="grey" stroke-width="2" stroke-dasharray="1, 5" />
  <line x1="20" y1="110" x2="280" y2="110" stroke="grey" stroke-width="2" stroke-dasharray="0.9" />
  <line x1="20" y1="130" x2="280" y2="130" stroke="grey" stroke-width="2" stroke-dasharray="15, 10, 5" />
  <line x1="20" y1="150" x2="280" y2="150" stroke="grey" stroke-width="2" stroke-dasharray="15, 10, 5, 10" />
  <line x1="20" y1="170" x2="280" y2="170" stroke="grey" stroke-width="2" stroke-dasharray="15, 10, 5, 10, 15" />
  <line x1="20" y1="190" x2="280" y2="190" stroke="grey" stroke-width="2" stroke-dasharray="5, 5, 1, 5" />
</svg>
stroke-linecap
 
<svg xmlns="http://www.w3.org/2000/svg" version="1.1" width="300px" height="200px">
  <line x1="20" y1="50" x2="280" y2="50" stroke="black" stroke-linecap="butt" stroke-width="20" />
  <line x1="20" y1="100" x2="280" y2="100" stroke="black" stroke-linecap="round" stroke-width="20" />
  <line x1="20" y1="150" x2="280" y2="150" stroke="black" stroke-linecap="square" stroke-width="20" />
</svg>
Rectangles
rect
 
<svg xmlns="http://www.w3.org/2000/svg" version="1.1" width="300px" height="200px">
  <rect x="1" y="1" width="119" height="39" fill="none" stroke="blue" stroke-width="2" />
</svg>
<svg xmlns="http://www.w3.org/2000/svg" version="1.1" width="300px" height="200px">
  <!-- black interior, no outline -->
  <rect x="10" y="10" width="100" height="80" />
  <!-- no interior, black outline -->
  <rect x="150" y="10" width="120" height="70" style="fill: none; stroke: black;" />
  <!-- blue interior, thick semi-transparent red outline -->
  <rect x="10" y="100" width="125" height="75" style="fill: #0000ff; stroke: red; stroke-width: 7; stroke-opacity: 0.5;" />
  <!-- semi-transparent yellow interior, dashed green outline -->
  <rect x="150" y="100" width="135" height="60" style="fill: yellow; fill-opacity: 0.5; stroke: green; stroke-width: 2; stroke-dasharray: 5 2" />
</svg>
black square
 
<svg xmlns="http://www.w3.org/2000/svg" version="1.1" width="300px" height="200px">
  <rect x="75" y="25" width="150" height="150" fill="black" />
</svg>
square
 
<svg xmlns="http://www.w3.org/2000/svg" version="1.1" width="300px" height="200px">
  <rect x="40" y="10" width="140" height="120" fill="yellow" stroke="navy" stroke-width="5" />
</svg>
rounded rectangles
rx, ry
 
<svg xmlns="http://www.w3.org/2000/svg" version="1.1" width="300px" height="200px">
  <rect x="10" y="10" width="250" height="150" rx="10" fill="green" />
</svg>
<svg xmlns="http://www.w3.org/2000/svg" version="1.1" width="300px" height="200px">
  <rect x="110" y="10" width="50" height="80" rx="5" style="stroke: black; fill: none;" />
  <rect x="210" y="10" width="50" height="80" ry="10" style="stroke: black; fill: none;" />
  <!-- rx and ry unequal -->
  <rect x="10" y="110" width="50" height="80" rx="10" ry="5" style="stroke: black; fill: none;" />
  <rect x="110" y="110" width="50" height="80" rx="5" ry="10" style="stroke: black; fill: none;" />
  <!-- rx and ry equal -->
  <rect x="210" y="110" width="50" height="50" rx="20" ry="20" style="stroke: black; fill: none;" />
</svg>
Links
a
 
<svg xmlns="http://www.w3.org/2000/svg" version="1.1" width="300px" height="200px">
  <a xlink:href="http://www.cheat-sheets.org/">
    <text x="50" y="30" font-size="12" text-decoration="underline" fill="blue">Cheat Sheets</text>
  </a>
  <a xlink:href="http://www.cheat-sheets.org/">
    <rect x="50" y="100" width="150" height="40" stroke-width="2" fill="yellowgreen" />
  </a>
</svg>
Cheat Sheets
Circles
circle
 
<svg xmlns="http://www.w3.org/2000/svg" version="1.1" width="300px" height="200px">
  <circle cx="150" cy="100" r="50" fill="blue" stroke="firebrick" stroke-width="3" />
</svg>
<svg xmlns="http://www.w3.org/2000/svg" version="1.1" width="300px" height="200px">
  <circle cx="35" cy="100" r="30" style="stroke: aqua; fill: none;" />
  <circle cx="125" cy="100" r="45" style="stroke-width: 5; stroke: aquamarine; fill: none;" />
  <circle cx="240" cy="100" r="60" fill="antiquewhite" />
</svg>
Ellipses
ellipse
 
<svg xmlns="http://www.w3.org/2000/svg" version="1.1" width="300px" height="200px">
  <ellipse transform="translate(150 60)" rx="125" ry="50" fill="red" />
</svg>
<svg xmlns="http://www.w3.org/2000/svg" version="1.1" width="300px" height="200px">
  <ellipse cx="80" cy="100" rx="30" ry="60" style="stroke: black; fill: none;" />
  <ellipse cx="210" cy="100" rx="60" ry="30" stroke="black" fill="none" />
</svg>
<svg xmlns="http://www.w3.org/2000/svg" version="1.1" width="300px" height="200px">
  <ellipse transform="translate(130 80) rotate(20)" rx="120" ry="50" fill="none" stroke="blue" stroke-width="20" />
</svg>
circle from ellipse
See also: circle
See also: ellipse
 
<svg xmlns="http://www.w3.org/2000/svg" version="1.1" width="300px" height="200px">
  <ellipse cx="150" cy="100" rx="80" ry="80" fill="none" stroke="black" />
</svg>
Polylines
polyline
 
<svg xmlns="http://www.w3.org/2000/svg" version="1.1" width="300px" height="200px">
  <polyline fill="none" stroke="greenyellow" stroke-width="3"
        points="   10,190      30,190      30,140      50,140
                        50,190      70,190      70,120      90,120
                        90,190    110,190    110,100    130,100
                      130,190    150,190    150,  80    170,  80
                      170,190    190,190    190,  60    210,  60
                      210,190    230,190    230,  40    250,  40
                      250,190    270,190    270,  20    290,  20" />
</svg>
stroke-linejoin
 
<svg xmlns="http://www.w3.org/2000/svg" version="1.1" width="300px" height="200px">
  <polyline stroke-linejoin="miter" stroke="black" stroke-width="12" fill="none" points="20,150 50,50 80,150"/>
  <polyline stroke-linejoin="round" stroke="black" stroke-width="12" fill="none" points="120,150 150,50 180,150"/>
  <polyline stroke-linejoin="bevel" stroke="black" stroke-width="12" fill="none" points="220,150 250,50 280,150"/>
</svg>
Polygons
polygon
 
<svg xmlns="http://www.w3.org/2000/svg" version="1.1" width="300px" height="200px">
  <title>Star</title</title>
  <polygon fill="red" stroke="blue" stroke-width="10"
        points="175,37.5 189.5,80.5 234.5,80.5 198.5,107.5 211.5,150.5 175,125 138.5,150.5 151.5,107.5 115.5,80.5 160.5,80.5" />
</svg>
Star
<svg xmlns="http://www.w3.org/2000/svg" version="1.1" width="300px" height="200px">
  <title>Hexagon</title>
  <polygon fill="lime" stroke="blue" stroke-width="3"
        points="125,37.5 179,68.75 179,131.25 125,162.5 71,131.3 71,68.75" />
</svg>
Hexagon
fill-rule
 
<svg xmlns="http://www.w3.org/2000/svg" version="1.1" width="300px" height="200px">
  <title>Stars</title>
  <polygon fill-rule="nonzero" fill="yellow" stroke="black" points="48,16 16,96 96,48 0,48 80,96" />
  <polygon fill-rule="evenodd" fill="#00ff00" stroke="black" points="148,16 116,96 196,48 100,48 180,96" />
</svg>
Stars
Pathes
path
absolute coordinates: H, L, M, V, Z, z
 
<svg xmlns="http://www.w3.org/2000/svg" version="1.1" width="300px" height="200px">
  <!-- single line: Move pen to (10, 10); Draw a line to (290, 190) -->
  <path d="M 10 10 L 290 190" stroke="black" fill="none" />
</svg>
<svg xmlns="http://www.w3.org/2000/svg" version="1.1" width="300px" height="200px">
  <!-- a angle: Move pen to (280,20); Draw a line to (10,190); Draw a line to (280,190) -->
  <path d="M 280,20 L 10,190 280,190" fill="none" stroke="brown" stroke-width="2" />
</svg>
<svg xmlns="http://www.w3.org/2000/svg" version="1.1" width="300px" height="200px">
  <path d="M 20,20 L 280,20 L 150,180 Z" fill="red" stroke="blue" stroke-width="3" />
</svg>
<svg xmlns="http://www.w3.org/2000/svg" version="1.1" width="300px" height="200px">
  <path d="M 150,20 V 180" stroke="cornflowerblue" stroke-width="4" />
</svg>
 
See also: vertical line
<svg xmlns="http://www.w3.org/2000/svg" version="1.1" width="300px" height="200px">
  <path d="M 20,100 H 280" stroke="darkcyan" stroke-width="4" />
</svg>
 
See also: horizontal line
path
relative coordinates: h, l, m, v, z
 
<svg xmlns="http://www.w3.org/2000/svg" version="1.1" width="300px" height="200px">
  <path d="m 20,10 v 180 m 40,0 l 180,-180 m 40,80 h -220" stroke="deeppink" fill="none" />
</svg>
Bézier Curves
Quadratic Bézier Curves
Q, q - quadratic Bézier curveto
T, t - shorthand/smooth quadratic Bézier curveto
 
<svg xmlns="http://www.w3.org/2000/svg" version="1.1" width="300px" height="200px">
  <path d="M 20,100 Q 150,20 280,100" stroke="black" fill="none" />
</svg>
<svg xmlns="http://www.w3.org/2000/svg" version="1.1" width="300px" height="200px">
  <path d="M 25,100 Q 50,0 75,100 T135,100 T185,100 T235,100 T275,100" stroke="black" fill="none" />
</svg>
<svg xmlns="http://www.w3.org/2000/svg" version="1.1" width="300px" height="200px">
  <path d="M 20,100 Q 150,-50 280,100" stroke="red" fill="none" />
  <path d="M 20,100 Q 150,0 280,100" stroke="orange" fill="none" />
  <path d="M 20,100 Q 150,50 280,100" stroke="yellow" fill="none" />
  <path d="M 20,100 Q 150,100 280,100" stroke="green" fill="none" />
  <path d="M 20,100 Q 150,150 280,100" stroke="blue" fill="none" />
  <path d="M 20,100 Q 150,200 280,100" stroke="darkblue" fill="none" />
  <path d="M 20,100 Q 150,250 280,100" stroke="violet" fill="none" />
</svg>
<svg xmlns="http://www.w3.org/2000/svg" version="1.1" width="300px" height="200px">
  <path d="M 20,150 Q -150,-100 280,150" stroke="red" fill="none" />
  <path d="M 20,150 Q -50,-100 280,150" stroke="orange" fill="none" />
  <path d="M 20,150 Q 50,-100 280,150" stroke="yellow" fill="none" />
  <path d="M 20,150 Q 150,-100 280,150" stroke="green" fill="none" />
  <path d="M 20,150 Q 250,-100 280,150" stroke="blue" fill="none" />
  <path d="M 20,150 Q 350,-100 280,150" stroke="darkblue" fill="none" />
  <path d="M 20,150 Q 450,-100 280,150" stroke="violet" fill="none" />
</svg>
Cubic Bézier Curves
С, с - quadratic Bézier curveto
S, s - shorthand/smooth quadratic Bézier curveto
 
<svg xmlns="http://www.w3.org/2000/svg" version="1.1" width="300px" height="200px">
  <path d="M 20,100 C 10,5 280,80 280,100" stroke="black" fill="none" />
</svg>
<svg xmlns="http://www.w3.org/2000/svg" version="1.1" width="300px" height="200px">
  <path d="M 25,100 C 30,0 60,20 75,100 S 130,130 135,100 S 180,70 185,100 S 230,130 235,100 S 280,70" stroke="black" fill="none" />
</svg>
<svg xmlns="http://www.w3.org/2000/svg" version="1.1" width="300px" height="200px">
  <path d="M 20,100 C 65,-50 235,0 280,100" stroke="red" fill="none" />
  <path d="M 20,100 C 65,0 235,0 280,100" stroke="orange" fill="none" />
  <path d="M 20,100 C 65,50 235,0 280,100" stroke="yellow" fill="none" />
  <path d="M 20,100 C 65,100 235,0 280,100" stroke="green" fill="none" />
  <path d="M 20,100 C 65,150 235,0 280,100" stroke="blue" fill="none" />
  <path d="M 20,100 C 65,200 235,0 280,100" stroke="darkblue" fill="none" />
  <path d="M 20,100 C 65,250 235,0 280,100" stroke="violet" fill="none" />
</svg>
<svg xmlns="http://www.w3.org/2000/svg" version="1.1" width="300px" height="200px">
  <path d="M 20,100 C 65,0 235,-50 280,100" stroke="red" fill="none" />
  <path d="M 20,100 C 65,0 235,0 280,100" stroke="orange" fill="none" />
  <path d="M 20,100 C 65,0 235,50 280,100" stroke="yellow" fill="none" />
  <path d="M 20,100 C 65,0 235,100 280,100" stroke="green" fill="none" />
  <path d="M 20,100 C 65,0 235,150 280,100" stroke="blue" fill="none" />
  <path d="M 20,100 C 65,0 235,200 280,100" stroke="darkblue" fill="none" />
  <path d="M 20,100 C 65,0 235,250 280,100" stroke="violet" fill="none" />
</svg>
<svg xmlns="http://www.w3.org/2000/svg" version="1.1" width="300px" height="200px">
  <path d="M 20,100 C -300,0 300,0 280,100" stroke="red" fill="none" />
  <path d="M 20,100 C -200,0 300,0 280,100" stroke="orange" fill="none" />
  <path d="M 20,100 C -100,0 300,0 280,100" stroke="yellow" fill="none" />
  <path d="M 20,100 C 0,0 300,0 280,100" stroke="green" fill="none" />
  <path d="M 20,100 C 100,0 300,0 280,100" stroke="blue" fill="none" />
  <path d="M 20,100 C 200,0 300,0 280,100" stroke="darkblue" fill="none" />
  <path d="M 20,100 C 300,0 300,0 280,100" stroke="violet" fill="none" />
</svg>
<svg xmlns="http://www.w3.org/2000/svg" version="1.1" width="300px" height="200px">
  <path d="M 20,100 C 0,0 0,0 280,100" stroke="red" fill="none" />
  <path d="M 20,100 C 0,0 100,0 280,100" stroke="orange" fill="none" />
  <path d="M 20,100 C 0,0 200,0 280,100" stroke="yellow" fill="none" />
  <path d="M 20,100 C 0,0 300,0 280,100" stroke="green" fill="none" />
  <path d="M 20,100 C 0,0 400,0 280,100" stroke="blue" fill="none" />
  <path d="M 20,100 C 0,0 500,0 280,100" stroke="darkblue" fill="none" />
  <path d="M 20,100 C 0,0 600,0 280,100" stroke="violet" fill="none" />
</svg>
Elliptical Arc
Elliptical Arc Curves
A rx ry x-axis-rotation large-arc-flag sweep-flag x y
a rx ry x-axis-rotation large-arc-flag sweep-flag x y
 
<svg xmlns="http://www.w3.org/2000/svg" version="1.1" width="300px" height="200px">
  <path d="M20,100 A80,30 0 1,1 220,150" fill="none" stroke="black" />
</svg>
x-axis-rotation
 
<svg xmlns="http://www.w3.org/2000/svg" version="1.1" width="300px" height="200px">
  <path d="M40,180 A70,30 -80 1,1 220,190" stroke="red" fill="none" />
  <path d="M40,180 A70,30 -50 1,1 220,190" stroke="orange" fill="none" />
  <path d="M40,180 A70,30 -30 1,1 220,190" stroke="yellow" fill="none" />
  <path d="M40,180 A70,30 0 1,1 220,190" stroke="green" fill="none" stroke-width="2" />
  <path d="M40,180 A70,30 30 1,1 220,190" stroke="blue" fill="none" />
  <path d="M40,180 A70,30 50 1,1 220,190" stroke="darkblue" fill="none" />
  <path d="M40,180 A70,30 80 1,1 220,190" stroke="violet" fill="none" />
</svg>
large-arc-flag and sweep-flag
 
<svg xmlns="http://www.w3.org/2000/svg" version="1.1" width="300px" height="200px">
  <path d="M120,70 A80,30 0 0,0 150,120" fill="none" stroke="red" stroke-width="2" />
  <path d="M120,70 A80,30 0 1,1 150,120" fill="none" stroke="orange" stroke-width="2" />
  <path d="M120,70 A80,30 0 0,1 150,120" fill="none" stroke="blue" stroke-width="2" />
  <path d="M120,70 A80,30 0 1,0 150,120" fill="none" stroke="violet" stroke-width="2" />
</svg>
<svg xmlns="http://www.w3.org/2000/svg" version="1.1" width="300px" height="200px">
  <path d="M120,70 A80,30 0 0,0 150,120" fill="none" stroke="black" />
</svg>
<svg xmlns="http://www.w3.org/2000/svg" version="1.1" width="300px" height="200px">
  <path d="M120,70 A80,30 0 1,1 150,120" fill="none" stroke="black" />
</svg>
<svg xmlns="http://www.w3.org/2000/svg" version="1.1" width="300px" height="200px">
  <path d="M120,70 A80,30 0 0,1 150,120" fill="none" stroke="black" />
</svg>
<svg xmlns="http://www.w3.org/2000/svg" version="1.1" width="300px" height="200px">
  <path d="M120,70 A80,30 0 1,0 150,120" fill="none" stroke="black" />
</svg>
circle from elliptical arc curves
See also: circle
 
<svg xmlns="http://www.w3.org/2000/svg" version="1.1" width="300px" height="200px">
  <path d="M20,100 A80,80 0 1,1 20,101 z" fill="none" stroke="black" />
</svg>
ellipse from elliptical arc curves
See also: ellipse
 
<svg xmlns="http://www.w3.org/2000/svg" version="1.1" width="300px" height="200px">
  <path d="M20,100 A80,30 0 1,1 20,101 z" fill="none" stroke="black" />
</svg>
sectors from elliptical arc curves
 
<svg xmlns="http://www.w3.org/2000/svg" version="1.1" width="300px" height="200px">
  <path d="M150,100 h-75 a75,75 0 1,0 75,-75 z" fill="red" stroke="blue" stroke-width="5" />
  <path d="M137.5,87.5 v-75 a75,75 0 0,0 -75,75 z" fill="yellow" stroke="blue" stroke-width="5" />
</svg>
Transform
transform
translate, rotate, scale, skewX, skewY
 
<svg xmlns="http://www.w3.org/2000/svg" version="1.1" width="300px" height="200px">
  <rect x="0" y="0" width="200" height="100" rx="5" fill="none" stroke="purple" stroke-width="30" />
</svg>
<svg xmlns="http://www.w3.org/2000/svg" version="1.1" width="300px" height="200px">
  <rect x="0" y="0" width="200" height="100" rx="5" fill="none" stroke="purple" stroke-width="30" transform="translate(60 51)" />
</svg>
<svg xmlns="http://www.w3.org/2000/svg" version="1.1" width="300px" height="200px">
  <rect x="0" y="0" width="200" height="100" rx="5" fill="none" stroke="purple" stroke-width="30" transform="translate(60 51) rotate(10)" />
</svg>
<svg xmlns="http://www.w3.org/2000/svg" version="1.1" width="300px" height="200px">
  <rect x="0" y="0" width="200" height="100" rx="5" fill="none" stroke="purple" stroke-width="30" transform="translate(60 51) rotate(-10)" />
</svg>
<svg xmlns="http://www.w3.org/2000/svg" version="1.1" width="300px" height="200px">
  <rect x="0" y="0" width="200" height="100" rx="5" fill="none" stroke="purple" stroke-width="30" transform="translate(60 51) skewX(10)" />
</svg>
<svg xmlns="http://www.w3.org/2000/svg" version="1.1" width="300px" height="200px">
  <rect x="0" y="0" width="200" height="100" rx="5" fill="none" stroke="purple" stroke-width="30" transform="translate(60 51) skewY(10)" />
</svg>
<svg xmlns="http://www.w3.org/2000/svg" version="1.1" width="300px" height="200px">
  <rect x="0" y="0" width="200" height="100" rx="5" fill="none" stroke="purple" stroke-width="30" transform="translate(60 51) skewX(10) skewY(10)" />
</svg>
<svg xmlns="http://www.w3.org/2000/svg" version="1.1" width="300px" height="200px">
  <rect x="0" y="0" width="200" height="100" rx="5" fill="none" stroke="purple" stroke-width="30" transform="translate(60 51) scale(0.6)" />
</svg>
<svg xmlns="http://www.w3.org/2000/svg" version="1.1" width="300px" height="200px">
  <rect x="0" y="0" width="200" height="100" rx="5" fill="none" stroke="purple" stroke-width="30" transform="translate(60 51) scale(0.2, 1.2)" />
</svg>
Grouping
g
 
<!-- From: J. David Eisenberg, SVG Essentials, Publisher: O'Reilly, First Edition February 2002, ISBN: 0-596-00223-8, 364 pages -->
<svg xmlns="http://www.w3.org/2000/svg" version="1.1" width="300px" height="200px"">
  <title>Grouped Drawing</title>
  <desc>Stick-figure drawings of a house and people</desc>
  <g id="house" style="fill: none; stroke: black;">
    <desc>House with door</desc>
    <rect x="6" y="50" width="60" height="60"/>
    <polyline points="6 50, 36 9, 66 50"/>
    <polyline points="36 110, 36 80, 50 80, 50 110"/>
  </g>
  <g id="man" style="fill: none; stroke: black;">
    <desc>Male human</desc>
    <circle cx="85" cy="56" r="10"/>
    <line x1="85" y1="66" x2="85" y2="80"/>
    <polyline points="76 104, 85 80, 94 104" />
    <polyline points="76 70, 85 76, 94 70" />
  </g>
  <g id="woman" style="fill: none; stroke: black;">
    <desc>Female human</desc>
    <circle cx="110" cy="56" r="10"/>
    <polyline points="110 66, 110 80, 100 90, 120 90, 110 80"/>
    <line x1="104" y1="104" x2="108" y2="90"/>
    <line x1="112" y1="90" x2="116" y2="104"/>
    <polyline points="101 70, 110 76, 119 70" />
  </g>
</svg>
Grouped Drawing Stick-figure drawings of a house and people House with door Male human Female human
use
 
<!-- From: J. David Eisenberg, SVG Essentials, Publisher: O'Reilly, First Edition February 2002, ISBN: 0-596-00223-8, 364 pages -->
<svg xmlns="http://www.w3.org/2000/svg" version="1.1" width="300px" height="200px"">
  <use xlink:href="#house" x="70" y="80"/>
  <use xlink:href="#woman" x="-80" y="80"/>
  <use xlink:href="#man" x="-30" y="80"/>
</svg>
defs
 
<!-- From: J. David Eisenberg, SVG Essentials, Publisher: O'Reilly, First Edition February 2002, ISBN: 0-596-00223-8, 364 pages -->
<svg xmlns="http://www.w3.org/2000/svg" version="1.1" width="300px" height="250px">
  <title>Grouped Drawing</title>
  <desc>Stick-figure drawings of a house and people</desc>
  <defs>
    <g id="house1" style="stroke: black;">
      <desc>House with door</desc>
      <rect x="0" y="41" width="60" height="60" />
      <polyline points="0 41, 30 0, 60 41" />
      <polyline points="30 101, 30 71, 44 71, 44 101" />
    </g>
    <g id="man1" style="fill: none; stroke: black;">
      <desc>Male human</desc>
      <circle cx="10" cy="10" r="10"/>
      <line x1="10" y1="20" x2="10" y2="44" />
      <polyline points="1 58, 10 44, 19 58" />
      <polyline points="1 24, 10 30, 19 24" />
    </g>
    <g id="woman1" style="fill: none; stroke: black;">
      <desc>Female human</desc>
      <circle cx="10" cy="10" r="10" />
      <polyline points="10 20, 10 34, 0 44, 20 44, 10 34" />
      <line x1="4" y1="58" x2="8" y2="44" />
      <line x1="12" y1="44" x2="16" y2="58" />
      <polyline points="1 24, 10 30, 19 24" />
    </g>
    <g id="couple1">
      <desc>Male and female human</desc>
      <use xlink:href="#man1" x="0" y="0" />
      <use xlink:href="#woman1" x="25" y="0" />
    </g>
  </defs>
  <!-- make use of the defined groups -->
  <use xlink:href="#house1" x="0" y="0" style="fill: #cfc;" />
  <use xlink:href="#couple1" x="70" y="40" />
  <use xlink:href="#house1" x="120" y="0" style="fill: #99f;" />
  <use xlink:href="#couple1" x="190" y="40" />
  <use xlink:href="#woman1" x="0" y="145" />
  <use xlink:href="#man1" x="25" y="145" />
  <use xlink:href="#house1" x="65" y="105" style="fill: #c00;" />
</svg>
Grouped Drawing Stick-figure drawings of a house and people House with door Male human Female human Male and female human
symbol
 
<!-- From: J. David Eisenberg, SVG Essentials, Publisher: O'Reilly, First Edition February 2002, ISBN: 0-596-00223-8, 364 pages -->
<svg xmlns="http://www.w3.org/2000/svg" version="1.1" width="300px" height="200px"">
  <symbol id="sym-octagon" stroke="black">
    <desc>Octagon as symbol</desc>
    <polygon points="36 25, 25 36, 11 36, 0 25, 0 11, 11 0, 25 0, 36 11" />
  </symbol>
  <use xlink:href="#sym-octagon" x="20" y="30" width="60" height="60" fill="#cfc"/>
  <use xlink:href="#sym-octagon" x="170" y="120" width="80" height="120" fill="#699" />
</svg>
Octagon as symbol
Markers
marker
marker-start, marker-mid, marker-end
 
<svg xmlns="http://www.w3.org/2000/svg" version="1.1" width="300px" height="200px">
  <defs>
    <marker id="mC" markerWidth="10" markerHeight="10" refX="5" refY="5">
      <circle cx="5" cy="5" r="4" style="fill: none; stroke: black;"/>
    </marker>
    <marker id="mA" markerWidth="6" markerHeight="10" refX="0" refY="4" orient="auto">
      <path d="M 0 0 4 4 0 8" style="fill: none; stroke: black;"/>
    </marker>
    <marker id="mT" markerWidth="5" markerHeight="10" refX="5" refY="5" orient="auto">
      <path d="M 0 0 5 5 0 10 Z" style="fill: black;"/>
    </marker>
  </defs>
  <path d="M20,20 H240 A 50,40 0 0,1 290,50 V180" marker-start="url(#mC)" marker-mid="url(#mA)" marker-end="url(#mT)" fill="none" stroke=" black" />
</svg>
line segment
 
<svg xmlns="http://www.w3.org/2000/svg" version="1.1" width="300px" height="200px">
  <defs>
    <marker id="mLS" markerWidth="1" markerHeight="10" refY="5" orient="auto">
      <line x1="0" y1="0" x2="0" y2="10" stroke="black"/>
    </marker>
  </defs>
  <line x1="20" y1="100" x2="280" y2="100" stroke="black" marker-start="url(#mLS)" marker-end="url(#mLS)" />
  <text x="16" y="90">A</text>
  <text x="276" y="90">B</text>
</svg>
A B
vector
 
<svg xmlns="http://www.w3.org/2000/svg" version="1.1" width="300px" height="200px">
  <defs>
    <marker id="mC2" markerWidth="5" markerHeight="5" refX="2.5" refY="2.5">
      <circle cx="2.5" cy="2.5" r="2.5" fill="black" stroke="black"/>
    </marker>
    <marker id="mT2" markerWidth="20" markerHeight="10" refX="20" refY="5" orient="auto">
      <path d="M0,0 L20,5 0,10 5,5 Z" style="fill: black;"/>
    </marker>
  </defs>
  <line x1="20" y1="150" x2="280" y2="50" stroke="black" marker-start="url(#mC2)" marker-end="url(#mT2)" />
  <text x="16" y="140">A</text>
  <text x="276" y="45">B</text>
</svg>
A B
Switch
switch
 
<svg xmlns="http://www.w3.org/2000/svg" version="1.1" width="300px" height="200px">
  <switch>
    <g systemLanguage="en-UK"><text x="10" y="100">en-UK: colour.</text></g>
    <g systemLanguage="en"><text x="10" y="100">en: color.</text></g>
    <g systemLanguage="es"><text x="10" y="100">es: color.</text></g>
    <g systemLanguage="en"><text x="10" y="100">ru: цвет.</text></g>
  </switch>
</svg>
en-UK: colour. en: color. es: color. ru: цвет.
Text on a Path
textPath
 
<svg xmlns="http://www.w3.org/2000/svg" version="1.1" width="300px" height="200px">
  <defs>
    <path id="curvepath" fill="none" d="M10 40 C 30 10, 50 10, 100 40 S 130 0, 180 40" />
    <path id="round-corner" fill="none" d="M200 30 L 250 30 A 30 30 0 0 1 280 60 L 280 110" />
    <path id="sharp-corner" fill="none" d="M10,110 L80,110 L80,160" />
    <path id="discontinuous" fill="none" d="M120,110 A 40 30 0 1 0 200,110 M220,110 L240,160" />
  </defs>
  <text><textPath xlink:href="#curvepath">Following a cubic Bézier curve.</textPath></text>
  <text><textPath xlink:href="#round-corner">Going 'round the bend</textPath></text>
  <text><textPath xlink:href="#sharp-corner">Making a quick turn</textPath></text>
  <text><textPath xlink:href="#discontinuous">Text along a broken path</textPath></text>
</svg>
Following a cubic Bézier curve. Going 'round the bend Making a quick turn Text along a broken path
ViewBox
viewBox
 
<!-- From: J. David Eisenberg, SVG Essentials, Publisher: O'Reilly, First Edition February 2002, ISBN: 0-596-00223-8, 364 pages -->
<svg xmlns="http://www.w3.org/2000/svg" version="1.1" width="300px" height="200px" viewBox="0 0 64 80">
  <title>House</title>
  <rect x="10" y="35" width="40" height="40" style="stroke: black; fill: none;" />
  <!-- roof -->
  <polyline points="10 35, 30 7.68, 50 35" style="stroke:black; fill: none;" />
  <!-- door -->
  <polyline points="30 75, 30 55, 40 55, 40 75" style="stroke:black; fill: none;" />
</svg>
House
<!-- From: J. David Eisenberg, SVG Essentials, Publisher: O'Reilly, First Edition February 2002, ISBN: 0-596-00223-8, 364 pages -->
<svg xmlns="http://www.w3.org/2000/svg" version="1.1" width="300px" height="200px" viewBox="0 0 90 90">
  <title>House</title>
  <rect x="10" y="35" width="40" height="40" style="stroke: black; fill: none;" />
  <!-- roof -->
  <polyline points="10 35, 30 7.68, 50 35" style="stroke:black; fill: none;" />
  <!-- door -->
  <polyline points="30 75, 30 55, 40 55, 40 75" style="stroke:black; fill: none;" />
</svg>
House
Patterns
pattern
 
<svg xmlns="http://www.w3.org/2000/svg" version="1.1" width="300px" height="200px">
  <defs>
    <pattern id="smPt" width="6" height="6" patternUnits="userSpaceOnUse">
      <rect width="5" height="5" stroke="chartreuse" stroke-width="2" />
      </pattern>
    </defs>
  <ellipse fill="url(#smPt)" stroke="indigo" stroke-width="5" cx="150" cy="100" rx="140" ry="50" />
</svg>
patternUnits
objectBoundingBox, userSpaceOnUse
 
<svg xmlns="http://www.w3.org/2000/svg" version="1.1" width="300px" height="200px">
  <defs>
    <pattern id="smPt1" x="0" y="0" width="40" height="20" patternUnits="objectBoundingBox">
      <rect x="0" y="0" width="40" height="20" stroke="darkturquoise" stroke-width="1" fill="none" />
    </pattern>
  </defs>
  <rect fill="url(#smPt1)" x="20" y="10" width="65" height="25" stroke="indianred" stroke-width="2" />
  <rect fill="url(#smPt1)" x="150" y="10" width="130" height="50" stroke="goldenrod" stroke-width="2" />
  <rect fill="url(#smPt1)" x="20" y="90" width="260" height="100" stroke="deeppink" stroke-width="2" />
</svg>
<svg xmlns="http://www.w3.org/2000/svg" version="1.1" width="300px" height="200px">
  <defs>
    <pattern id="smPt2" x="0" y="0" width="40" height="20" patternUnits="userSpaceOnUse">
      <rect x="0" y="0" width="40" height="20" stroke="darkturquoise" stroke-width="1" fill="none" />
    </pattern>
  </defs>
  <rect fill="url(#smPt2)" x="20" y="10" width="65" height="25" stroke="indianred" stroke-width="2" />
  <rect fill="url(#smPt2)" x="150" y="10" width="130" height="50" stroke="goldenrod" stroke-width="2" />
  <rect fill="url(#smPt2)" x="20" y="90" width="260" height="100" stroke="deeppink" stroke-width="2" />
</svg>
<svg xmlns="http://www.w3.org/2000/svg" version="1.1" width="300px" height="200px">
  <defs>
    <pattern id="smPt3" x="0" y="0" width="80%" height="80%" patternUnits="objectBoundingBox">
      <rect x="0" y="0" width="40" height="20" stroke="darkturquoise" stroke-width="1" fill="none" />
    </pattern>
  </defs>
  <rect fill="url(#smPt3)" x="20" y="10" width="65" height="25" stroke="indianred" stroke-width="2" />
  <rect fill="url(#smPt3)" x="150" y="10" width="130" height="50" stroke="goldenrod" stroke-width="2" />
  <rect fill="url(#smPt3)" x="20" y="90" width="260" height="100" stroke="deeppink" stroke-width="2" />
</svg>
<svg xmlns="http://www.w3.org/2000/svg" version="1.1" width="300px" height="200px">
  <defs>
    <pattern id="smPt4" x="0" y="0" width="80%" height="80%" patternUnits="userSpaceOnUse">
      <rect x="0" y="0" width="40" height="20" stroke="darkturquoise" stroke-width="1" fill="none" />
    </pattern>
  </defs>
  <rect fill="url(#smPt4)" x="20" y="10" width="65" height="25" stroke="indianred" stroke-width="2" />
  <rect fill="url(#smPt4)" x="150" y="10" width="130" height="50" stroke="goldenrod" stroke-width="2" />
  <rect fill="url(#smPt4)" x="20" y="90" width="260" height="100" stroke="deeppink" stroke-width="2" />
</svg>
Gradients
linearGradient
stop, offset, stop-color
 
<svg xmlns="http://www.w3.org/2000/svg" version="1.1" width="300px" height="200px">
  <defs>
    <linearGradient id="two_hues">
      <stop offset="0%" style="stop-color: #ffcc00;"/>
      <stop offset="100%" style="stop-color: #0099cc;"/>
    </linearGradient>
  </defs>
  <rect x="20" y="20" width="260" height="160" style="fill: url(#two_hues); stroke: black;"/>
</svg>
radialGradient
stop, offset, stop-color
 
<svg xmlns="http://www.w3.org/2000/svg" version="1.1" width="300px" height="200px">
  <defs>
    <radialGradient id="three_stops">
      <stop offset="0%" style="stop-color: #f96;"/>
      <stop offset="50%" style="stop-color: #9c9;"/>
      <stop offset="100%" style="stop-color: #906;"/>
    </radialGradient>
  </defs>
  <rect x="60" y="10" width="180" height="180" style="fill: url(#three_stops); stroke: black;"/>
</svg>
Animation
animate
 
<svg xmlns="http://www.w3.org/2000/svg" version="1.1" width="300px" height="300px">
  <circle cx="150" cy="150" r="10" fill="greenyellow" stroke="orangered" stroke-width="2">
    <animate attributeName="r" to="150" dur="180s" repeatCount="indefinite" />
  </circle>
</svg>
dur
 
<svg xmlns="http://www.w3.org/2000/svg" version="1.1" width="300px" height="300px">
  <circle cx="150" cy="150" r="10" fill="none" stroke="purple" stroke-width="2">
    <animate attributeName="r" to="150" dur="120s" repeatCount="indefinite" />
  </circle>
  <circle cx="150" cy="150" r="10" fill="none" stroke="royalblue" stroke-width="2">
    <animate attributeName="r" to="150" dur="60s" repeatCount="indefinite" />
  </circle>
</svg>
fill (animate)
freeze, remove
 
<svg xmlns="http://www.w3.org/2000/svg" version="1.1" width="300px" height="300px">
  <rect x="50" y="50" width="10" height="100" fill="none" stroke="steelblue" stroke-width="3">
    <animate attributeName="width" to="200" dur="60s" fill="freeze" />
  </rect>
  <rect x="50" y="170" width="10" height="100" fill="none" stroke="teal" stroke-width="3">
    <animate attributeName="width" to="200" dur="60s" fill="remove" />
  </rect>
</svg>
animateColor
 
<svg xmlns="http://www.w3.org/2000/svg" version="1.1" width="300px" height="300px">
  <ellipse transform="translate(150,150)" rx="125" ry="50" fill="blue">
    <animateColor to="red" attributeName="fill" begin="5s" dur="20s" fill="freeze" repeatCount="indefinite" />
  </ellipse>
</svg>
animateMotion
 
<svg xmlns="http://www.w3.org/2000/svg" version="1.1" width="300px" height="300px">
  <path id="path1" d="M70,250 C 70,100 220,50 220,250" fill="none" stroke="blue" stroke-width="3" />
  <path d="M-12.5,-6.75 L12.5,-6.75 L 0,-43.75 z" fill="yellow" stroke="red" stroke-width="3">
    <animateMotion dur="6s" repeatCount="indefinite" rotate="auto" >
      <mpath xlink:href="#path1"/>
    </animateMotion>
  </path>
</svg>
animateTransform
 
<svg xmlns="http://www.w3.org/2000/svg" version="1.1" width="300px" height="300px">
  <title>Golden Watch</title>
  <circle cx="150" cy="150" r="140" fill="ghostwhite" stroke="goldenrod" stroke-width="2" />
  <circle cx="150" cy="150" r="130" fill="none" stroke="goldenrod" stroke-width="3" stroke-dasharray="2,13.613568" transform="rotate(-.12)" />
  <line y2="-130" stroke="gold" stroke-width="1" transform="translate(150,150) rotate(0)">
    <animateTransform attributeName="transform" type="rotate" repeatCount="indefinite" dur="60s" by="360" />
  </line>
  <line y2="-120" stroke="gold" stroke-width="2" transform="translate(150,150) rotate(0)">
    <animateTransform attributeName="transform" type="rotate" repeatCount="indefinite" dur="60min" by="360" />
  </line>
  <line y2="-110" stroke="gold" stroke-width="3" transform="translate(150,150) rotate(0)">
    <animateTransform attributeName="transform" type="rotate" repeatCount="indefinite" dur="12h" by="360" />
  </line>
</svg>
Golden Watch
Scripting
script
 
<svg xmlns="http://www.w3.org/2000/svg" version="1.1" width="300px" height="300px">
  <script>
<![CDATA[
function circle_click(evt) {
  var circle = evt.target;
  var currentRadius = circle.getAttribute("r");
  if (currentRadius == 25) {
    circle.setAttribute("r", currentRadius*2);
  } else {
    circle.setAttribute("r", currentRadius*0.5);
  };
};
// ]]>
  </script>
  <circle cx="150" cy="100" r="25" fill="red" onclick="circle_click(evt)" />
  <text x="150" y="175" text-anchor="middle">Click on circle to change its size.</text>
</svg>
Click on circle to change its size.
The End