mask-origin

This is an experimental technology
Check the Browser compatibility table carefully before using this in production.

The mask-origin CSS property determines the origin of a mask.

/* Keyword values */
mask-origin: content-box;
mask-origin: padding-box;
mask-origin: border-box;
mask-origin: margin-box;
mask-origin: fill-box;
mask-origin: stroke-box;
mask-origin: view-box;

/* Multiple values */
mask-origin: padding-box, content-box;
mask-origin: view-box, fill-box, border-box;

/* Non-standard keyword values */
-webkit-mask-origin: content;
-webkit-mask-origin: padding;
-webkit-mask-origin: border;

/* Global values */
mask-origin: inherit;
mask-origin: initial;
mask-origin: unset;

For elements rendered as a single box, this property specifies the mask positioning area. In other words, this property specifies the origin position of an image specified by the mask-image CSS property. For elements rendered as multiple boxes, such as inline boxes on several lines or boxes on several pages, it specifies which boxes box-decoration-break operates upon to determine the mask positioning area.

Initial valueborder-box
Applies toall elements; In SVG, it applies to container elements excluding the <defs> element and all graphics elements
Inheritedno
Mediavisual
Computed valueas specified
Animation typediscrete
Canonical orderper grammar

Syntax

One or more of the keyword values listed below, separated by commas.

Values

content-box
The position is relative to the content box.
padding-box
The position is relative to the padding box. For single boxes 0 0 is the upper left corner of the padding edge, 100% 100% is the lower right corner.
border-box
The position is relative to the border box.
margin-box
The position is relative to the margin box.
fill-box
The position is relative to the object bounding box.
stroke-box
The position is relative to the stroke bounding box.
view-box
Uses the nearest SVG viewport as reference box. If a viewBox attribute is specified for the element creating the SVG viewport, the reference box is positioned at the origin of the coordinate system established by the viewBox attribute and the dimension of the reference box is set to the width and height values of the viewBox attribute.
content
Same as content-box.
padding
Same as padding-box.
border
Same as border-box.

Formal syntax

<geometry-box>#

where
<geometry-box> = <shape-box> | fill-box | stroke-box | view-box

where
<shape-box> = <box> | margin-box

where
<box> = border-box | padding-box | content-box

Example

CSS

#masked {
  width: 100px;
  height: 100px;
  margin: 10px;
  border: 10px solid blue;
  background-color: #8cffa0;
  padding: 10px;
  mask-image: url(https://mdn.mozillademos.org/files/12676/star.svg);
  mask-origin: border-box; /* Can be changed in the live sample */
}

Specifications

Specification Status Comment
CSS Masking Module Level 1
The definition of 'mask-origin' in that specification.
Candidate Recommendation Initial definition

Browser compatibility

 

Update compatibility data on GitHub
DesktopMobile
ChromeEdgeFirefoxInternet ExplorerOperaSafariAndroid webviewChrome for AndroidEdge MobileFirefox for AndroidOpera for AndroidiOS SafariSamsung Internet
Basic support
Experimental
Chrome Full support Yes
Prefixed Notes
Full support Yes
Prefixed Notes
Prefixed Requires the vendor prefix: -webkit-
Notes The margin-box value is unsupported.
Edge ? Firefox Full support 53IE ? Opera Full support Yes
Prefixed Notes
Full support Yes
Prefixed Notes
Prefixed Requires the vendor prefix: -webkit-
Notes The margin-box value is unsupported.
Safari Full support Yes
Prefixed Notes
Full support Yes
Prefixed Notes
Prefixed Requires the vendor prefix: -webkit-
Notes The margin-box value is unsupported.
WebView Android ? Chrome Android ? Edge Mobile ? Firefox Android Full support 53Opera Android ? Safari iOS ? Samsung Internet Android ?
fill-box
Experimental
Chrome No support NoEdge ? Firefox No support NoIE No support NoOpera ? Safari ? WebView Android ? Chrome Android ? Edge Mobile ? Firefox Android No support NoOpera Android ? Safari iOS ? Samsung Internet Android No support No
stroke-box
Experimental
Chrome No support NoEdge ? Firefox No support NoIE No support NoOpera ? Safari ? WebView Android ? Chrome Android ? Edge Mobile ? Firefox Android No support NoOpera Android ? Safari iOS ? Samsung Internet Android No support No
view-box
Experimental
Chrome No support NoEdge ? Firefox No support NoIE No support NoOpera ? Safari ? WebView Android ? Chrome Android ? Edge Mobile ? Firefox Android No support NoOpera Android ? Safari iOS ? Samsung Internet Android No support No
Non-standard values content, padding, border
ExperimentalNon-standard
Chrome Full support 1
Prefixed
Full support 1
Prefixed
Prefixed Requires the vendor prefix: -webkit-
Edge ? Firefox No support NoIE No support NoOpera No support NoSafari Full support 4
Prefixed
Full support 4
Prefixed
Prefixed Requires the vendor prefix: -webkit-
WebView Android Full support 2
Prefixed
Full support 2
Prefixed
Prefixed Requires the vendor prefix: -webkit-
Chrome Android ? Edge Mobile ? Firefox Android No support NoOpera Android ? Safari iOS Full support 3.2
Prefixed
Full support 3.2
Prefixed
Prefixed Requires the vendor prefix: -webkit-
Samsung Internet Android ?

Legend

Full support  
Full support
No support  
No support
Compatibility unknown  
Compatibility unknown
Experimental. Expect behavior to change in the future.
Experimental. Expect behavior to change in the future.
Non-standard. Expect poor cross-browser support.
Non-standard. Expect poor cross-browser support.
See implementation notes.
See implementation notes.
Requires a vendor prefix or different name for use.
Requires a vendor prefix or different name for use.

 

Document Tags and Contributors

Last updated by: fscholz,