CSS mask-mode Property

❮ Previous Reference Next ❯


.example {
  -webkit-mask-image: url(hello-world.png);
  mask-image: url(hello-world.png);
  -webkit-mask-size: 60%;
  mask-size: 60%;
  -webkit-mask-repeat: no-repeat;
  mask-repeat: no-repeat;
  mask-mode: luminance;


The mask-mode property sets whether the mask reference defined by mask-image is treated as a luminance or alpha mask.

Default value:match-source
JavaScript syntax:

Standard Syntax

mask-mode: match-source|luminance|alpha|initial|inherit|revert|revert-layer|unset;

Browser Support

The numbers in the table specify the first browser version that fully supports the property.


Property Values

The following table describes the values of this property.

Value Description
match-source This is default. If the mask-image property is an image (an image URL or a gradient), set mask-mode to alpha. If the mask-image property is an SVG <mask> element, use the <mask> element's mask-type property.
luminance Specifies that the luminance values of the mask layer image should be used as the mask values.
alpha Specifies that the transparency (alpha channel) values of the mask layer image should be used as the mask values.
initial Sets this property to its default value.
inherit If specified, the associated element takes the computed value of its parent element animation-delay property.
revert Reverts the cascaded value of the property from its current value to the value the property
revert-layer Rollback styles to the ones specified in previous cascade layers.
unset Resets a property to its inherited value if the property naturally inherits from its parent, and to its initial value if not.

Default CSS Property Values

selectors {
  mask-mode: match-source;

More Examples

This is the mask image:


And this is an image of flowers:


After apply the mask image as the mask layer for the image flowers:


<style type="text/css">
img {
  -webkit-mask-image: url(hello-world.png);
  mask-image: url(hello-world.png);
  -webkit-mask-size: 100%;
  mask-size: 100%;
  -webkit-mask-repeat: no-repeat;
  mask-repeat: no-repeat;

<img src="flowers.jpg" width="200" height="200">
❮ Previous Reference Next ❯