CSS mask-size Property

Definition and Usage

mask-size This property specifies the size of the mask layer image.

Example

Example 1

Set the size of the mask layer image (in percentage):

.mask1 {
  -webkit-mask-image: url(w3logo.png);
  mask-image: url(w3logo.png);
  mask-size: 70%;
  mask-repeat: no-repeat;
}

Try It Yourself

Example 2

Set the size of the mask layer image (in pixels):

.mask1 {
  -webkit-mask-image: url(w3logo.png);
  mask-image: url(w3logo.png);
  mask-size: 200px 200px;
  mask-repeat: no-repeat;
}

Try It Yourself

CSS Syntax

mask-size: auto|size|contain|cover|initial|inherit;

Property Value

Value Description
auto Default Value.
size Specify the size of the masked image, which can be in units such as px, em, or %.
contain Scale the masked image so that both its width and height can fit inside the container.
cover Scale the masked image so that both its width and height can cover the container.
initial Sets this property to its default value. See initial.
inherit Inherits this property from its parent element. See inherit.

Technical Details

Default Value: auto
Inheritance: No
Animation Creation: Not supported. See:Animation-related Properties.
Version: CSS Masking Module Level 1
JavaScript Syntax: object.style.maskSize="100px 200px"

Browser Support

The numbers in the table represent the first browser version to fully support this property.

Chrome Edge Firefox Safari Opera
120 120 53 15.4 106

Related Pages

Tutorial:CSS Mask

Reference:CSS mask Property

Reference:CSS mask-clip Property

Reference:CSS mask-composite Property

Reference:CSS mask-image Property

Reference:CSS mask-mode Property

Reference:CSS mask-origin Property

Reference:CSS mask-position Property

Reference:CSS mask-repeat Property

Reference:CSS mask-type Property