The mask-size property sets how large a mask-image is drawn. Leave it at its natural size with auto, stretch it with lengths or percentages, or fit the box with cover and contain while keeping the aspect ratio.
The initial value is auto. The property is not inherited. Percentages are relative to the mask positioning area from mask-origin (default padding-box). Pair it with mask-repeat: no-repeat when a smaller size should not tile.
Standard-track.
Not deprecated and not experimental. Unprefixed mask-size is Baseline widely available. Older Safari needed -webkit-mask-size. Gradients have no intrinsic size, so prefer a file or SVG with width and height when studying cover vs contain.
Two values mean width then height.100px 60px draws the mask at exactly that size.
One value would set only the width.100px alone keeps height as auto and preserves the ratio when the mask has one.
Percentages use the positioning area.50% is half the width of the area from mask-origin, not half of the SVG file.
Negative sizes are invalid. The browser ignores a negative length or percentage.
Edge Cases & Pitfalls
If the mask looks tiled, stretched wrong, or unchanged, one of these is usually why.
image
No mask-image, no scaling
mask-size only sizes an active mask layer. Set mask-image first, or use the mask shorthand that includes one.
repeat
contain can tile by default
If the scaled mask is smaller than the box, mask-repeat starts at repeat and fills the gaps with copies. Use no-repeat for a single silhouette.
gradient
Gradients have no natural size
CSS gradients have no intrinsic dimensions. With auto, they often fill the positioning area, so cover and contain can look the same. Use a file or SVG with width and height to study the keywords.
crop
cover always may crop
When the box ratio differs from the mask ratio, edges are cut off. Keep important shape detail near the center, or switch to contain.
shorthand
The mask shorthand resets size
A later mask declaration that omits size resets mask-size to auto for that layer. Set size after the shorthand, or include it in the shorthand.
Compatibility
Browser Support
mask-size is a browser painting property for CSS masking. Node.js, Deno, and Bun do not apply it. Unprefixed support is Baseline. Older WebKit used -webkit-mask-size.
✓ Baseline · Widely available since Dec 2023
mask-size
Unprefixed: Chrome 120+, Edge 120+, Firefox 53+, Safari 15.4+. Prefixed WebKit support is older. Internet Explorer has no CSS mask-size.
97%Modern browser support
Google Chrome120+ unprefixed · older with -webkit-
Full support
Mozilla Firefox53+
Full support
Apple Safari15.4+ unprefixed · older with -webkit-
Full support
Microsoft Edge120+ unprefixed
Full support
Opera106+ unprefixed
Full support
Samsung Internet25+ unprefixed
Full support
Internet ExplorerNo support
None
mask-sizeWidely supported
Bottom line: Safe for current browsers with the unprefixed property. Add -webkit-mask-size only if you must support older Safari or Chromium builds before the Baseline versions above. Prefer a mask with intrinsic size when teaching or testing cover vs contain. Do not treat this as a Node.js or other runtime feature.
Remember
Key Takeaways
Role: set how large the mask image is drawn inside the box.
Keywords:cover fills (may crop); contain fits (may leave gaps); auto is the default.
Two values: width then height. One value sets width; height becomes auto.
Pair with:no-repeat and often center for logos and cutouts.
One line:mask-size answers “how big is this mask image inside the box?”
Frequently Asked Questions
It sets the width and height of a mask image. You can keep the natural size, stretch with lengths or percentages, or use cover and contain to fit the box while keeping the aspect ratio.
auto, which is the same as auto auto. A mask with intrinsic size keeps that size. The property is not inherited.
cover scales up until the box is filled and may crop edges. contain scales until the whole mask fits and may leave empty bands. Both keep the aspect ratio.
The default mask-repeat is repeat. If the scaled mask is smaller than the box, it tiles. Pair contain (or a length size) with mask-repeat: no-repeat when you want one copy.
No. There must be a mask-image (or a mask shorthand that sets one). Without a mask layer, changing mask-size has nothing to scale.
Unprefixed mask-size is Baseline and widely available since December 2023: Chrome 120+, Edge 120+, Firefox 53+, Safari 15.4+. Older WebKit browsers used -webkit-mask-size. Internet Explorer does not support it. This is a browser CSS property. Node.js, Deno, and Bun do not paint it.