Languages

HTML / CSS - how can I add border to svg element?

0 points
Asked by:
Lani-Skinner
748

How can I add border to my svg element?

Let's say I have the following code:

1 answer
0 points
Answered by:
Admin Dirask Community
4380

You can use stroke and stroke-width properties to create a border for your svg element.

Note:

The stroke may go out of the vievBox, so you will need to adjust it e.g viewBox="-2 -2 515 515".

Practical example

In this example, we use:

  • fill - to change the color of the element to yellow,
  • stroke-width - to set the svg element border width,
  • stroke - to set the border color.

Note:

You can also use rgba() colors to fill element with partly transparent color or assign it to stroke to create semi-transparent border.

0 commentsAdd comment
Donate to Dirask
Our content is created by volunteers - like Wikipedia. If you think, the things we do are good, donate us. Thanks!
Join to our subscribers to be up to date with content, news and offers.
Native Advertising
🚀
Get your tech brand or product in front of software developers.
For more information Contact us
Dirask - we help you to
solve coding problems.
Ask question.

❤️💻 🙂

Join