CKTIS / CSS
stroke-linecap — stroke end shapes
The CSS stroke-linecap property sets stroke endings to flat, rounded, or square shapes. In SVG it affects the ends of open subpaths and individual dashes, but it does not control the shape of corners.
Version: CSS modules; structured CSSWG indexes reconciled with pinned MDN BCD; Chromium 152 scope gate; usage example verification passed
Syntax
stroke-linecap: butt | round | square;stroke-linecap controls stroke endings, including those of SVG lines and open subpaths. It also affects the ends of individual dashes. The property is inherited, its initial value is butt, and its animation type is discrete: shapes do not morph smoothly.
butt cuts the stroke off at the path endpoints. round adds a semicircle with a radius of half the stroke-width. square adds a rectangle, extending the stroke by half the stroke-width at each end. The latter two values increase the visible length without changing the path coordinates.
For a zero-length subpath, such as M 40 40 L 40 40, butt paints nothing, round produces a circle, and square produces a square whose side equals the stroke width. A lone moveto command, without a drawing command, produces no stroke.
Do not confuse this property with stroke-linejoin, which controls corners. A continuous closed path of nonzero length has no free ends. To see the effect, set a visible stroke and a positive stroke-width; the example compares all three caps.
Examples
<!doctype html>
<meta charset="utf-8">
<title>stroke-linecap</title>
<style>
line { stroke: #1565c0; stroke-width: 20px; }
#butt { stroke-linecap: butt; }
#round { stroke-linecap: round; }
#square { stroke-linecap: square; }
</style>
<svg xmlns="http://www.w3.org/2000/svg" width="240" height="150" viewBox="0 0 240 150" role="img" aria-label="stroke-linecap: butt, round, square">
<line id="butt" x1="40" y1="30" x2="200" y2="30" />
<line id="round" x1="40" y1="75" x2="200" y2="75" />
<line id="square" x1="40" y1="120" x2="200" y2="120" />
</svg>Result
Top to bottom: three blue horizontal strokes with butt, round, and square caps. The butt stroke spans x=40–200; the round and square strokes span x=30–210. All strokes are 20 units 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.