The shape elements provide the foundational visual building blocks of an SVG.
In this section we'll discuss the basic shape elements and their attributes. A more detailed discussion of the presentation attributes that define look of the shape elements can be found here .
The path is the most powerful shape element, allowing for the most visual complexity. We’ll be exploring the path element in detail in the next section.
1
2
3
<svg width="500" height="500" viewbox="0 0 500 500">
<circle cx="250" cy="250" r="200" fill="orange" />
</svg>
1
2
3
<svg width="500" height="500" viewbox="0 0 500 500">
<ellipse cx="250" cy="250" rx="200" ry="100" fill="orange" />
</svg>
1
2
3
<svg width="500" height="500" viewbox="0 0 500 500">
<rect x="50" y="50" width="400" height="400" fill="orange"></rect>
</svg>
1
2
3
4
5
6
7
8
9
10
11
<svg width="500" height="500" viewbox="0 0 500 500">
<rect
x="50"
y="50"
width="400"
height="400"
rx="20"
ry="20"
fill="orange"
></rect>
</svg>
1
2
3
<svg width="500" height="500" viewbox="0 0 500 500">
<line x1="100" y1="100" x2="400" y2="400" stroke="black" />
</svg>
1
2
3
4
5
6
7
<svg width="500" height="500" viewbox="0 0 500 500">
<polyline
points="60,60 90,390 140,70 190,414 240,70 290,350 340,60 390,265 440,80"
stroke="black"
fill="none"
/>
</svg>
1
2
3
4
5
6
7
<svg width="500" height="500" viewbox="0 0 500 500">
<polyline
points="60,60 90,390 140,70 190,414 240,70 290,350 340,60 390,265 440,80"
stroke="black"
fill="orange"
/>
</svg>
1
2
3
4
5
6
7
<svg width="500" height="500" viewbox="0 0 500 500">
<polygon
points="60,60 240,215 440,60 440,340 340,440 140,430 60,340"
fill="none"
stroke="black"
/>
</svg>
The image element allows you to add bitmap images - pngs or jpegs - to your svg.
1
2
3
4
5
<svg width="500" height="500" viewbox="0 0 500 500">
<image
href="https://plus.unsplash.com/premium_vector-1724876723896..."
x="50" y="50" height="400" width="400" />
</svg>
Shapes are stacked in order of appearance, with later elements on top.
1
2
3
4
<svg width="500" height="500" viewbox="0 0 500 500">
<rect x="200" y="100" width="200" height="200" fill="lightgrey"></rect>
<circle cx="200" cy="300" r="100" fill="orange" />
</svg>