{{SVGRefElem}}
The clipping path restricts the region to which paint can be applied. Conceptually, any parts of the drawing that lie outside of the region bounded by the currently active clipping path are not drawn.
A clipping path is defined with a clipPath
element. A clipping path is used/referenced using the {{SVGAttr("clip-path")}} property.
A clipping path is conceptually equivalent to a custom viewport for the referencing element. Thus, it affects the rendering of an element, but not the element's inherent geometry. The bounding box of a clipped element (meaning, an element which references a clipPath
element via a {{SVGAttr("clip-path")}} property, or a child of the referencing element) must remain the same as if it were not clipped.
By default, pointer-events must not be dispatched on the clipped (non-visible) regions of a shape. For example, a circle with a radius of 10 which is clipped to a circle with a radius of 5 will not receive "click" events outside the smaller radius.
Usage context
{{svginfo}}
Example
<svg width="120" height="120" viewBox="0 0 120 120" xmlns="https://www.w3.org/2000/svg"> <defs> <clipPath id="myClip"> <circle cx="30" cy="30" r="20"/> <circle cx="70" cy="70" r="20"/> </clipPath> </defs> <rect x="10" y="10" width="100" height="100" clip-path="url(#myClip)"/> </svg>
Live sample
{{EmbedLiveSample('Example','140','140')}}
Attributes
Global attributes
- Conditional processing attributes »
- Core attributes »
- Presentation attributes »
- {{SVGAttr("class")}}
- {{SVGAttr("style")}}
- {{SVGAttr("externalResourcesRequired")}}
- {{SVGAttr("transform")}}
Specific attributes
- {{SVGAttr("clipPathUnits")}}
DOM Interface
This element implements the SVGClipPathElement
interface.
Specifications
Specification | Status | Comment |
---|---|---|
{{SpecName('SVG1.1', 'masking.html#EstablishingANewClippingPath', '<clipPath>')}} | {{Spec2('SVG1.1')}} | Initial definition |
Browser compatibility
{{CompatibilityTable}}
Feature | Chrome | Firefox (Gecko) | IE | Opera | Safari |
---|---|---|---|---|---|
Basic support | {{CompatChrome('1.0')}} | {{CompatGeckoDesktop('1.8')}} | {{CompatIE('9.0')}} | {{CompatOpera('9.0')}} | {{CompatSafari('3.0.4')}} |
Feature | Android | Firefox Mobile (Gecko) | IE Phone | Opera Mobile | Safari Mobile |
---|---|---|---|---|---|
Basic support | {{CompatAndroid('3.0')}} | {{CompatGeckoMobile('1.8')}} | {{CompatNo}} | {{CompatVersionUnknown}} | {{CompatSafari('3.0.4')}} |
The chart is based on these sources.
Related
- {{SVGElement("mask")}}
- {{SVGAttr("clip-path")}}
{{SVGRef}}