CKTIS / CSS
fill-rule — determining a shape’s interior
The CSS `fill-rule` property determines which regions belong to an SVG shape’s interior. Its `nonzero` and `evenodd` values can produce different results for intersecting or nested subpaths.
Version: CSS modules; structured CSSWG indexes reconciled with pinned MDN BCD; Chromium 152 scope gate, per-example verification still required
Syntax
fill-rule: nonzero | evenodd;fill-rule selects how a shape’s interior is determined, not its fill color. Its initial value is nonzero; the property is inherited, and its animation is discrete.
nonzero sums crossings between the outline and a ray extending from the tested point, accounting for crossing direction. A nonzero sum means inside. evenodd ignores direction: an odd number of crossings means inside, and an even number means outside.
Nested subpaths within one path, running in the same direction, produce a filled center with nonzero but a hole with evenodd. This is not a subtraction operation between separate elements. The example demonstrates that difference using identical geometry.
The supplied drafts differ in their scope for text: SVG 2 lists shapes and text content elements, whereas CSS Fill and Stroke explicitly excludes text. This entry and its example are limited to SVG shapes.
Examples
<!doctype html>
<meta charset="utf-8">
<title>fill-rule</title>
<style>
svg { background: white; }
path { fill: #0066cc; }
.nonzero { fill-rule: nonzero; }
.evenodd { fill-rule: evenodd; }
</style>
<svg xmlns="http://www.w3.org/2000/svg" width="240" height="120" viewBox="0 0 240 120" role="img" aria-label="nonzero / evenodd">
<path class="nonzero" d="M10 10H110V110H10Z M35 35H85V85H35Z"/>
<path class="evenodd" transform="translate(120 0)" d="M10 10H110V110H10Z M35 35H85V85H35Z"/>
</svg>Result
Left: a solid blue square. Right: a blue square with a white square opening at its center.
The displayed code and declared result were verified in an isolated environment using the method recorded in the verification evidence for this exact version.