Knowledge baseExam Center
ENEnglish
Choose language13

CKTIS / CSS

shape-rendering — SVG shape-rendering hints

The shape-rendering property sets priorities for rendering SVG shapes: speed, crisp edges, or geometric precision.

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

Syntax

shape-rendering: auto | optimizeSpeed | crispEdges | geometricPrecision;

shape-rendering provides a rendering hint for SVG shapes, such as paths and circles. It is inherited; its initial value is auto. Animation is discrete, without smooth interpolation between values.

auto balances the goals, favoring geometric precision. optimizeSpeed favors speed and may disable antialiasing. crispEdges favors sharp edges: the browser may disable antialiasing or align line positions and widths with device pixels. geometricPrecision favors geometric precision.

These are hints, not a guarantee of particular pixel output. In the example, compare the left triangle (crispEdges) with the right (geometricPrecision); a visible difference is not required.

Examples

<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Rendering hints for SVG triangle outlines</title>
<style>
  #left { shape-rendering: crispEdges; }
  #right { shape-rendering: geometricPrecision; }
</style>
</head>
<body>
<svg width="240" height="100" viewBox="0 0 240 100" role="img" aria-labelledby="triangles">
  <title id="triangles">Two triangle outlines with different rendering hints</title>
  <path id="left" d="M10 80 L50 15 L90 80 Z" fill="none" stroke="black" />
  <path id="right" d="M130 80 L170 15 L210 80 Z" fill="none" stroke="black" />
</svg>
<p>The two outlines may look different depending on the renderer. These values are hints, not guarantees about individual pixels.</p>
<script>
  const names = { crispedges: 'crispEdges', geometricprecision: 'geometricPrecision' };
  for (const side of ['left', 'right']) {
    const value = getComputedStyle(document.getElementById(side)).getPropertyValue('shape-rendering');
    console.log(`${side} triangle outline: ${names[value.toLowerCase()] ?? value}`);
  }
</script>
</body>
</html>

Result

left triangle outline: crispEdges
right triangle outline: geometricPrecision

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