CSS Portal

CSS vector-effect Property

If this site has been useful, we’d love your support! Consider buying us a coffee to keep things going strong!

Description

The vector-effect property controls how vector graphics rendering treats stroke geometry when the underlying shapes are transformed or scaled. Rather than changing the shape outline itself, it modifies whether the visible stroke thickness follows the element’s geometric transformations or remains tied to a fixed rendering scale. This is primarily relevant for stroked vector elements (it does not affect fills) and is commonly used in SVG contexts where shapes are scaled by viewport or coordinate system changes.

One common usage pattern is to preserve consistent visual weight for lines and icons as they are scaled. By choosing an appropriate rendering mode you can keep the stroke drawn at a stable thickness even when the element is enlarged or shrunk, which helps maintain legibility for icons, diagrams, and map features. This interacts closely with the element’s specified stroke thickness (see stroke-width) and the way you apply geometric transformations — whether through CSS or SVG — such as with transform.

There are practical implications to consider: preserving stroke thickness can make hit‑testing, visual alignment, and the apparent relationship between adjacent shapes behave differently than when strokes scale with geometry. It also affects how strokes look when an element is placed inside a scaled viewBox or nested inside transformed groups. Depending on your rendering needs, you may combine this behavior with other stroke-related presentation settings like stroke to achieve consistent styling across sizes. Use the property where visual consistency across scales is more important than having the stroke scale proportionally with the vector geometry.

Definition

Initial value
none
Applies to
graphics elements , structural element
Inherited
no
Computed value
as specified
Animatable
yes
JavaScript syntax
object.style.vectorEffect

Syntax

selector { vector-effect: value; }

Values

  • noneThe default behavior. The stroke scales along with the object. If you double the size of the shape, the stroke width also doubles.
  • non-scaling-strokeThe most popular value. It ensures the stroke width remains constant regardless of any transformations (scaling, stretching) applied to the element.
  • non-scaling-size(Experimental/Partial support) The element's size does not scale, but it can still be translated.
  • non-rotation(Experimental/Partial support) The element does not rotate even if its parent or coordinate system does.
  • fixed-position(Experimental/Partial support) The element maintains a fixed position regardless of transformations.

Example

<div class="container">
<div class="box">
<p>Default (Stroke Scales)</p>
<svg viewBox="0 0 100 100">
<rect class="default-stroke" x="10" y="10" width="80" height="80" />
</svg>
</div>

<div class="box">
<p>vector-effect: non-scaling-stroke</p>
<svg viewBox="0 0 100 100">
<rect class="vector-stroke" x="10" y="10" width="80" height="80" />
</svg>
</div>
</div>
svg {
  width: 150px;
  height: 150px;
  background: #f4f4f4;
  /* Scaling the SVG up to see the effect */
  transform: scale(3);
  margin: 100px;
}

rect {
  fill: none;
  stroke: #ff4757;
  stroke-width: 2px;
}

/* The magic property */
.vector-stroke {
  vector-effect: non-scaling-stroke;
}

/* Layout styling */
.container {
  display: flex;
  gap: 250px;
  padding: 50px;
}

Browser Support

The following information will show you the current browser support for the CSS vector-effect 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
Chrome
Edge
Firefox
Opera
Safari
Tablets & Mobile
Chrome Android
Firefox Android
Opera Android
Safari iOS
Samsung Internet
Android WebView
-

Last updated by CSSPortal on: 28th December 2025

If this site has been useful, we’d love your support! Consider buying us a coffee to keep things going strong!