Path: blob/main/files/en-us/web/svg/attribute/clip-rule/index.md
6581 views
------{{SVGRef}}
« SVG Attribute reference home
The clip-rule attribute only applies to graphics elements that are contained within a {{ SVGElement("clipPath") }} element. The clip-rule attribute basically works as the {{ SVGAttr("fill-rule") }} attribute, except that it applies to {{ SVGElement("clipPath") }} definitions.
The following fragment of code will cause an evenodd clipping rule to be applied to the clipping path because clip-rule is specified on the {{ SVGElement("path") }} element that defines the clipping shape:
whereas the following fragment of code will not cause an evenodd clipping rule to be applied because the clip-rule is specified on the referencing element, not on the object defining the clipping shape:
As a presentation attribute, it also can be used as a property directly inside a CSS stylesheet
Usage notes
| Value | nonzero | evenodd | inherit |
|---|---|
| Default value | nonzero |
| Animatable | Yes |
nonzero
: See description of {{ SVGAttr("fill-rule") }} property.
evenodd
: See description of {{ SVGAttr("fill-rule") }} property.
Example
{{ EmbedLiveSample('Example', '100%', '110') }}
Elements
The following elements can use the clip-rule attribute, but only if they are inside a {{ SVGElement("clipPath") }} element.
Browser compatibility
{{Compat}}
See also
{{ SVGElement("clipPath") }}