Vachmi

The <polygon> element is used to draw shapes with multiple sides (at least 3).
A polygon is a closed shaped made of multiple sides and vertices.

Here is the SVG code to draw this polygon.

<svg width="200" height="150">
  <polygon points="0,100 200,125 200,25 0,50" style="fill: none; stroke:black; />
</svg>

Code Explanation

• points attribute of polygon is used to define the x and y coordinates of all vertices of the polyline.

• Polygon draws lines between all the points defines by points attribute including the line between first and the last point.

• This is the main difference between polygon and polyline.

• Polyline does not draw a line between last point and the first point. Polygon does. That seesm to be the only difference between polygon and polyline.

Attributes

points - The points attribute defines the list of points (pairs of x,y absolute coordinates) required to draw the polygon.

It can accept a number as its value.