Knowledge baseExam Center
ENEnglish
Choose language13

CKTIS / CSS

stroke — painting SVG outlines

The CSS `stroke` property specifies how an SVG shape or text outline is painted. Stroke color is independent of the fill and line width. This entry distinguishes the SVG 2 model from the expanded CSS Fill and Stroke proposal.

Version: CSS modules; structured CSSWG indexes reconciled with pinned MDN BCD; Chromium 152 scope gate. The usage example passed isolated verification; target-browser compatibility is a separate check.

Syntax

stroke: <paint>;
/* SVG 2: <paint> = none | <color> | <url> [ none | <color> ]? | context-fill | context-stroke */

In SVG 2, stroke specifies the outline paint for SVG shapes and text. Its initial value is none, and it is inherited. fill controls the interior, while stroke-width controls outline thickness. It is not a shorthand that sets line width.

The value can be a color, including currentColor, or url(#paint) referencing an SVG gradient or pattern. In url(#paint) red, red is a fallback for an invalid reference, not an additional layer. none disables stroke painting. SVG 2 also defines the contextual values context-fill and context-stroke.

The CSS Fill and Stroke Level 3 draft describes a broader stroke shorthand for painting properties such as stroke-color and stroke-image. Do not equate that proposal with the SVG 2 model or assume support merely because stroke is supported. The syntax and example here use the SVG 2 model.

The example should display a circle with a blue, 4px-wide outline and no painted fill. The code and expected result were verified in an isolated environment. Check compatibility with the target browser separately.

Examples

<!doctype html>
<meta charset="utf-8">
<title>stroke</title>
<style>
  circle {
    fill: none;
    stroke: #0066cc;
    stroke-width: 4px;
  }
</style>
<svg xmlns="http://www.w3.org/2000/svg" width="120" height="120" viewBox="0 0 120 120">
  <circle cx="60" cy="60" r="40" />
</svg>

Result

A circle with a blue (#0066cc), 4px-wide stroke and no painted fill.

The displayed code and declared result were verified in an isolated environment using the method recorded in the verification evidence for this exact version.

Sources