CKTIS / CSS
stroke-opacity — stroke paint opacity
The CSS `stroke-opacity` property controls the opacity of stroke painting independently of the fill. It accepts a number or percentage, is inherited, and has an initial value of `1`.
Version: CSS modules; structured CSSWG indexes reconciled with pinned MDN BCD; Chromium 152 scope gate, per-example verification still required
Syntax
stroke-opacity: <number> | <percentage>;
stroke-opacity: inherit | initial | unset | revert | revert-layer;stroke-opacity sets the opacity of the operation that paints the outline of SVG shapes and text. It does not create a stroke: painting a stroke requires visible paint from stroke and a nonzero effective stroke width. A separate stroke-width declaration is not required: its initial value is already nonzero, and a nonzero value can also be inherited. stroke-opacity is not a replacement for CSS border properties.
Values of 0 and 0% mean fully transparent, while 1 and 100% mean fully opaque for this operation. 0.25 is equivalent to 25%. The computed value is a number clamped to [0, 1]; out-of-range values are clamped rather than rejected. The initial value is 1, the property is inherited, and it can be animated by computed value.
Unlike opacity, which affects the rendered result of an entire element or group, stroke-opacity does not directly change the fill. It should not be confused with fill-opacity either. In the example, only the right stroke has opacity 0.25; both gold fills remain opaque.
Examples
<!doctype html>
<meta charset="utf-8">
<title>stroke-opacity</title>
<style>
svg { background: white; }
rect { fill: gold; stroke: black; stroke-width: 12; }
.faded { stroke-opacity: 0.25; }
</style>
<svg xmlns="http://www.w3.org/2000/svg" width="240" height="120" viewBox="0 0 240 120">
<rect x="20" y="20" width="80" height="80" />
<rect class="faded" x="140" y="20" width="80" height="80" />
</svg>Result
Two gold squares. The left stroke is opaque black; the right stroke has 25% opacity. Both fills remain opaque.
The displayed code and declared result were verified in an isolated environment using the method recorded in the verification evidence for this exact version.