The stroke-width attribute is an attribute defining the width of the stroke applied to the shape.
Syntax:
stroke-width="length"
Attribute Values:
- length: Length at which we want to set the stroke-width attribute
- percentage: Percentage at which we want to set the stroke-width attribute
We will use the stroke-width attribute for setting the width of the element.
Example 1: In this example we will use the stroke-width attribute for setting the width of rect using length value.
<!DOCTYPE html>
< html >
< body >
< svg viewBox = "0 0 110 80"
< circle cx = "15" cy = "15" r = "3"
stroke = "green" stroke-width = "11" />
</ svg >
</ body >
</ html >
|
Output:

Example 2: In this example, we will use the stroke-width attribute for setting the width of rect using percentage value.
<!DOCTYPE html>
< html >
< body >
< svg viewBox = "0 0 110 80"
< circle cx = "20" cy = "20" r = "6"
stroke = "green" stroke-width = "20%" />
</ svg >
</ body >
</ html >
|
Output

Whether you're preparing for your first job interview or aiming to upskill in this ever-evolving tech landscape,
GeeksforGeeks Courses are your key to success. We provide top-quality content at affordable prices, all geared towards accelerating your growth in a time-bound manner. Join the millions we've already empowered, and we're here to do the same for you. Don't miss out -
check it out now!
Last Updated :
31 Mar, 2022
Like Article
Save Article