CSS stroke-linecap Property
Description
The stroke-linecap property determines how the visible ends of open stroked paths are rendered — in other words, the shape that appears at the start and end points of a line, segment, or open subpath when you draw its outline. This influences the apparent length and silhouette of strokes, because the chosen cap style can either stop exactly at the endpoint, extend beyond it, or round off the end. The effect is immediately noticeable on single straight segments, polylines, and the ends of dashed strokes, and it plays an important role in the overall visual rhythm and legibility of stroked vector artwork.
Because cap geometry is tied to the stroke itself, stroke-linecap interacts closely with other stroke-related properties. For example, the result scales with the stroke-width — thicker strokes produce proportionally larger end shapes — and the cap shape changes how segments meet or appear separated when you use dashed outlines set by stroke-dasharray. Similarly, while joins control the connection between adjacent segments, stroke-linejoin governs corners and the cap behavior only affects open ends; together these properties let you fine-tune the appearance of a stroked path. The visual color and opacity of the stroke, set by stroke, naturally combine with the cap shape to produce the final rendered edge.
In practical terms, choosing the right end-cap behavior helps solve common design needs: making line ends look crisp and mechanically precise for technical diagrams, softening ends for more organic iconography, or ensuring that dashes visually align or overlap in a predictable way. Caps also affect pixel-snapping and perceived alignment — small differences can be important at hairline widths or when precise endpoints must match other geometry. Finally, because the cap is part of the stroke geometry, it is affected by transforms and scaling, so consider how scaling or device pixel ratios will change the cap’s apparent size and how that impacts layout and interaction in responsive graphics.
Definition
- Initial value
- butt
- Applies to
- <circle>, <ellipse>, <line>, <path>, <polygon>, <polyline>, and <rect> elements in an svg
- Inherited
- yes
- Computed value
- as specified
- Animatable
- yes
- JavaScript syntax
- object.style.strokeLinecap
Syntax
element { stroke-linecap: butt | round | square; }
Values
- buttThe default value. The stroke ends abruptly at the exact endpoint of the path. It has a flat edge and adds no extra length.
- roundAdds a semi-circle to the end of the stroke. The radius of this curve is equal to half of the
stroke-width. - squareAdds a rectangular cap to the end of the stroke. It looks like
butt, but extends the stroke by a distance equal to half thestroke-width.
Example
Browser Support
The following information will show you the current browser support for the CSS stroke-linecap property. Hover over a browser icon to see the version that first introduced support for this CSS property.
This property is supported by all modern browsers.
Desktop
Tablets & Mobile
Last updated by CSSPortal on: 28th December 2025
