The Wayback Machine - https://web.archive.org/web/20220211203708/https://www.geeksforgeeks.org/svg-fill-opacity-attribute/
Skip to content
Related Articles

Related Articles

Improve Article
Save Article
Like Article

SVG fill-opacity Attribute

  • Last Updated : 27 Oct, 2020

The fill-opacity attribute is a presentation attribute defining the opacity of the paint applied to a shape.

Syntax:

fill-opacity="colour"

Attribute Values:

  • decimal: Decimal value at which we want to make our element opaque.
  • percentage: Percentage at which we want to set the fill-opacity attribute.

We will use the fill-opacity attribute for setting the opacity of fill-color.

Example 1: 




<!DOCTYPE html> 
<html> 
  
<body> 
    <svg viewBox="0 0 400 100" 
         xmlns="http://www.w3.org/2000/svg">
        <circle cx="50" cy="50" r="35" fill="green"/>
  
        <circle cx="150" cy="50" r="35" fill="green"
        fill-opacity="0.7" />
    </svg>
</body> 
  
</html>

Output:

Example 2: 




<!DOCTYPE html> 
<html> 
  
<body> 
    <svg viewBox="0 0 400 100"
        xmlns="http://www.w3.org/2000/svg">
        <circle cx="60" cy="60" r="40" fill="black"/>
  
        <circle cx="150" cy="60" r="40" fill="black"
        fill-opacity="25%" />
    </svg>
</body> 
  
</html>

Output:

Attention reader! Don’t stop learning now. Get hold of all the important HTML concepts with the Web Design for Beginners | HTML  course.


My Personal Notes arrow_drop_up
Recommended Articles
Page :

Start Your Coding Journey Now!