Knowledge baseExam Center
ENEnglish
Choose language13

CKTIS / CSS

vector-effect — SVG strokes without thickness scaling

The `vector-effect` property changes how SVG renders under transformations. The `non-scaling-stroke` value preserves stroke thickness while the geometry continues to scale.

Version: CSS modules; structured CSSWG indexes reconciled with pinned MDN BCD; Chromium 152 scope gate, per-example verification still required

Syntax

vector-effect: none | non-scaling-stroke | non-scaling-size | non-rotation | fixed-position;

vector-effect applies to SVG graphics elements and use. Its initial value, none, means normal rendering; the property is not inherited. Set it directly on the painted elements rather than relying on a setting on a group.

non-scaling-stroke calculates the stroke in the SVG host coordinate space, so scaling the geometry does not increase stroke thickness. It does not prevent scaling of the shape itself or its fill. This distinction is useful for map lines that should remain readable after scaling, for example.

The supplied syntax reflects the property table in the SVG 2 draft. That draft marks non-scaling-size, non-rotation, and fixed-position as at risk of removal because of missing implementations; do not treat them as a portable foundation for production code.

In the example, scale(3) lengthens both lines. At 100% browser zoom, each line is expected to be 180 CSS pixels long, with a 12 CSS pixel stroke on the upper line and a 4 CSS pixel stroke on the lower line.

Examples

<!doctype html>
<meta charset="utf-8">
<style>
  line { stroke: black; stroke-width: 4px; }
  .fixed { vector-effect: non-scaling-stroke; }
</style>
<svg xmlns="http://www.w3.org/2000/svg" width="240" height="120" viewBox="0 0 240 120">
  <g transform="scale(3)">
    <line x1="10" y1="10" x2="70" y2="10" />
    <line class="fixed" x1="10" y1="30" x2="70" y2="30" />
  </g>
</svg>

Result

Expected at 100% browser zoom: two horizontal black lines, each 180 CSS px long; the upper stroke is 12 CSS px thick and the lower stroke is 4 CSS px 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.

Sources