- SVG Tutorial
- SVG Examples
- A Simple SVG Example
- Displaying SVG in Web Browsers
- SVG Icons
- SVG Coordinate System
- SVG svg element
- SVG g element
- SVG rect element
- SVG circle element
- SVG ellipse element
- SVG line element
- SVG polyline element
- SVG polygon element
- SVG path element
- SVG marker element
- SVG text element
- SVG tspan element
- SVG tref element
- SVG textpath element
- SVG switch element
- SVG image element
- SVG a element
- SVG defs Elements
- SVG symbol Element
- SVG use Element
- SVG and CSS - Cascading Style Sheets
- SVG Stroke
- SVG Fill
- SVG Viewport and View Box
- SVG Animation
- SVG Scripting
- SVG Transformation
- SVG Gradients
- SVG Fill Patterns
- SVG Clip Path
- SVG Masks
- SVG Filters
SVG polygon element
Jakob Jenkov |
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="http://www.w3.org/2000/svg"
xmlns:xlink="http://www.w3.org/1999/xlink">
<polygon points="10,0 60,0 35,50"
style="stroke:#660000; fill:#cc3333;"/>
</svg>
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="http://www.w3.org/2000/svg"
xmlns:xlink="http://www.w3.org/1999/xlink">
<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;"/>
</svg>
| Tweet | |
Jakob Jenkov | |







