O'Reilly logo

Designing SVG Web Graphics by Andrew H. Watt

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

The <polygon> Element

The <polygon> element is used for a shape with multiple (at least three) straight sides. Figure 03.15 and the following example show a hexagon with a red stroke and a gray fill.

Figure 03.15. A hexagon created using the <polygon> element.

Listing 3.17. (Polygon01.svg)
<?xml version="1.0" standalone="no"?> 
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.0//EN" 
      "http://www.w3.org/TR/2001/PR-SVG-20010719/ 
       DTD/svg10.dtd"> 
<svg width="400" height="500" > 
<polygon style="fill:#CCC; stroke:red; stroke-width:3" 
points="150,75 258,137.5 258,262.5 
150,325 42,262.5 42,137.5" /> 
</svg> 

If you were so inclined, you could create a rectangle ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required