Tutorials Books About

1 SVG Tutorial
2 SVG Examples
3 A Simple SVG Example
4 Displaying SVG in Web Browsers
5 SVG Coordinate System
6 SVG svg element
7 SVG g element
8 SVG rect element
9 SVG circle element
10 SVG ellipse element
11 SVG line element
12 SVG polyline element
13 SVG polygon element
14 SVG path element
15 SVG marker element
16 SVG text element
17 SVG tspan element
18 SVG tref element
19 SVG textpath element
20 SVG switch element
21 SVG image element
22 SVG a element
23 SVG defs Elements
24 SVG symbol Element
25 SVG use Element
26 SVG and CSS - Cascading Style Sheets
27 SVG Stroke
28 SVG Fill
29 SVG Viewport and View Box
30 SVG Animation
31 SVG Scripting
32 SVG Transformation
33 SVG Gradients
34 SVG Fill Patterns
35 SVG Clip Path
36 SVG Masks
37 SVG Filters

SVG polygon element

The SVG <polygon> element is used to draw shapes with multiple (3 or more) sides / edges.

SVG Polygon - Video Tutorial

Here is a video version of this tutorial:

SVG Polygon Example

Here is a simple SVG polygon example:

<svg xmlns=""

  <polygon points="10,0  60,0  35,50"
         style="stroke:#660000; fill:#cc3333;"/>


Here is the resulting image:

You may notice that all 3 sides are drawn, even if only 3 points are listed. That is because the <polygon> element draws lines between all points, including a line from the last point back to the first. The <polyline> does NOT draw a line from the last point to the first. This seems to be the only difference the <polygon> and the <polyline> elements.

Here is a larger example - an 8-sided polygon (octagon?):

<svg xmlns=""

  <polygon points="50,5   100,5  125,30  125,80 100,105
                   50,105  25,80  25, 30"
          style="stroke:#660000; fill:#cc3333; stroke-width: 3;"/>


Connect with me: Newsletter - Get all my free tips!