SVG Opacity vs Fill-Opacity with Overlapping Shapes

Understanding the difference between opacity and fill-opacity is essential when rendering overlapping SVG shapes, as each property controls transparency at a fundamentally different stage of the rendering pipeline. While fill-opacity adjusts the alpha channel of only the interior paint of an element, opacity applies uniform transparency to the entire rendered object or group as a single composited layer. This distinction drastically alters the visual output, creating either compounded blend regions or a seamless, uniform transparency across overlapping geometries.

How fill-opacity Affects Overlapping Shapes

The fill-opacity attribute dictates the alpha value applied strictly to the fill paint server of a shape. It operates directly at the rasterization stage of the individual path.

How opacity Affects Overlapping Shapes

The opacity attribute controls the transparency of an entire SVG element or group (<g>) after all sub-components and children are rendered.

Key Differences Summary

Feature fill-opacity opacity
Scope Only affects the interior fill color Affects fill, stroke, and all child elements
Group Overlaps Intersections between shapes appear darker Intersections within a group remain uniform
Compositing Method Direct per-pixel painting Off-screen buffer flattening, then alpha blend
Performance Minimal overhead Higher memory/rendering cost on complex groups

Practical Selection Guide