SVG opacity Attribute
The opacity attribute specifies the transparency of an object or of a group of objects.
Syntax:
opacity= "opacity"
Attribute Values:
- decimal: The decimal at which we want to make our element opaque
We will use the opacity attribute for setting the opacity of the element.
Example 1: In this example we will use the opacity attribute for setting the opacity of circle element.
<!DOCTYPE html><html> <body> <svg viewBox="0 0 700 350" <circle cx="50" cy="50" r="40" fill="green" /> <circle cx="150" cy="50" r="40" fill="green" opacity="0.3" /> </svg></body> </html> |
Output:
Example 2: In this example we will use the opacity attribute for setting the opacity of rectangle element.
<!DOCTYPE html><html> <body> <svg viewBox="0 0 700 350" <rect height="50" width="50" fill="green" opacity="0.3" /> </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.

