Opacity (SVG)
The fill-opacity, and stroke-opacity SVG attributes and CSS properties control the transparency of a stroke or fill of an SVG element.
Overview
The fill-opacity, and stroke-opacity SVG attributes and CSS properties control the transparency of a stroke or fill of an SVG element.
Browser support
| Feature | Desktop | Mobile | ||||
|---|---|---|---|---|---|---|
| Chrome | Edge | Firefox | Safari | Chrome Android | Safari iOS | |
| 1 | ≤15 | 1 | 4 | 18 | 3.2 | |
| Other | ||||||
| The stroke-opacity CSS property defines the opacity of an SVG shape's stroke. The effect is identical to that of opacity, except it is applied only to the stroke, not to the entire element. If present, it overrides the element's stroke-opacity attribute. | 1 | ≤15 | 1.5 | 4 | 18 | 3.2 |
| The fill-opacity attribute is a presentation attribute defining the opacity of the paint server (color, gradient, pattern, etc.) applied to a shape. | ≤80 | ≤80 | 1 | ≤13.1 | ≤80 | ≤13.4 |
| The stroke-opacity attribute is a presentation attribute defining the opacity of the paint server (color, gradient, pattern, etc.) applied to the stroke of a shape. | ≤80 | ≤80 | 1 | ≤13.1 | ≤80 | ≤13.4 |
Syntax
circle {
fill: blue;
fill-opacity: 0.5;
}
path {
stroke: red;
stroke-opacity: 0.8;
} Live demo
Use cases
Using Opacity (SVG)
The fill-opacity, and stroke-opacity SVG attributes and CSS properties control the transparency of a stroke or fill of an SVG element.
Cautions
- May not be supported in older browsers.
Accessibility
- Make sure visual changes are conveyed appropriately to assistive technology.
Related links
Powered by web-features