SVG stroke-opacity attribute

The stroke-opacity attribute specifies the transparency of an object or of a group of objects.

Syntax:

stroke-opacity= "opacity"

Attribute Values:

  • decimal: decimal value ranging from 0-1
  • percentage: percentage at which we want to set the opacity of the element

We will use the stoke-opacity attribute for setting the opacity of the element.

Example 1: In this example we will use the stroke-opacity attribute for setting the opacity of circle element using decimal attribute.



filter_none

edit
close

play_arrow

link
brightness_4
code

<!DOCTYPE html> 
<html
  
<body
    <svg viewBox="0 0 40 10" 
         xmlns="http://www.w3.org/2000/svg">
        <circle cx="5" cy="5" r="4" stroke="green" />
  
        <circle cx="15" cy="5" r="4" stroke="green"
        stroke-opacity="0.7" />
  
    </svg>
</body
  
</html>

chevron_right


Output:

Example 2: In this example we will use the stroke-opacity attribute for setting the opacity of circle element using percentage attribute.

filter_none

edit
close

play_arrow

link
brightness_4
code

<!DOCTYPE html> 
<html
  
<body
    <svg viewBox="0 0 40 35" 
         xmlns="http://www.w3.org/2000/svg">
        <circle cx="5" cy="5" r="3" stroke="green" />
  
        <circle cx="15" cy="5" r="3" stroke="green"
        stroke-opacity="50%" />
  
    </svg>
</body
  
</html>

chevron_right


Output:

full-stack-img




My Personal Notes arrow_drop_up

Check out this Author's contributed articles.

If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.

Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.


Article Tags :
Practice Tags :


Be the First to upvote.


Please write to us at contribute@geeksforgeeks.org to report any issue with the above content.