CKTIS / CSS
stroke-width — SVG stroke thickness
The CSS stroke-width property sets the thickness of strokes on SVG shapes and text. It is inherited and accepts a nonnegative length, percentage, or number in SVG user units. Setting the thickness alone does not give the stroke a color.
Version: CSS modules; structured CSSWG indexes reconciled with pinned MDN BCD; Chromium 152 scope gate, per-example verification still required
Syntax
stroke-width: <length-percentage> | <number>; /* SVG 2; nonnegative values */stroke-width sets the thickness of the painted stroke on SVG shapes and text, rather than the border of a rectangular CSS box. Its initial value is 1px, and the property is inherited. A visible stroke also requires a suitable stroke, such as stroke: black; the initial stroke: none paints no stroke.
SVG 2 accepts a length such as 2px, a percentage, or a unitless number such as 2, which represents SVG user units. A value of 0 disables stroke painting, whereas a negative value is invalid. Percentages refer to the normalized diagonal of the current SVG viewport, not the object's width or the path's length.
The sources describe different scopes: the CSS Fill and Stroke Level 3 draft proposes the syntax [ <length-percentage> | <line-width> ]#, stroke layers, and a different percentage basis. Do not equate those draft extensions with SVG 2 behavior or assume browser support for them. This entry and example use single length values for SVG; they do not establish Chromium 152 compatibility.
In the example, the upper line inherits stroke-width: 2px from svg, while .thick sets the lower line's thickness to 8px. The viewBox and viewport dimensions match, so there is no additional scaling. The expected result is two black horizontal lines with thicknesses of 2 and 8 CSS pixels, respectively.
Examples
<!doctype html>
<html lang="en">
<meta charset="utf-8">
<title>stroke-width</title>
<style>
svg { stroke: black; stroke-width: 2px; }
.thick { stroke-width: 8px; }
</style>
<svg xmlns="http://www.w3.org/2000/svg" width="200" height="100" viewBox="0 0 200 100" role="img" aria-label="Two horizontal lines with different stroke widths">
<line x1="20" y1="30" x2="180" y2="30" />
<line class="thick" x1="20" y1="70" x2="180" y2="70" />
</svg>
</html>Result
Two black horizontal lines: the upper line is 2 CSS pixels thick and the lower line is 8 CSS pixels thick.
The displayed code and declared result were verified in an isolated environment using the method recorded in the verification evidence for this exact version.