The mask-origin property defines the positioning area for a mask-image — similar to how background-origin works for backgrounds.
01
border-box
Default origin area.
02
padding-box
Inside the border.
03
content-box
Inner content only.
04
With mask-image
Requires a mask layer.
05
WebKit
Prefix for Safari.
06
Related
mask-position, size.
Fundamentals
Introduction
The mask-origin property in CSS defines the origin of the mask image used on an element. It determines the positioning area for the mask — similar to the background-origin property for background images.
This property is particularly useful when you want to control how the mask image is applied to an element’s content box, padding box, or border box. Pair it with mask-image, mask-size, and mask-position for precise mask placement.
Definition and Usage
Use mask-origin: border-box (the default) when the mask should align with the outer edge including the border. Use padding-box to start positioning inside the border, or content-box when the mask should align only with the inner content area.
💡
Beginner Tip
Add a visible border and padding to your element, then switch between border-box, padding-box, and content-box — the mask will shift relative to each box edge, making the difference easy to see.
Foundation
📝 Syntax
The syntax for the mask-origin property uses one of three box-model keyword values:
syntax.css
element{mask-origin:value;}
Here, value can be one of the specified keywords: border-box, padding-box, or content-box.
mask-origin only applies when a mask-image is set.
border-box includes the border area in the positioning reference.
padding-box starts positioning at the outer edge of the padding (inside the border).
Include -webkit-mask-origin alongside mask-origin for broader Safari support.
Cheat Sheet
⚡ Quick Reference
Question
Answer
Initial value
border-box
Applies to
All elements
Inherited
No
Animatable
No
Common use
Aligning mask-image positioning to border, padding, or content edges
Reference
💎 Property Values
The mask-origin property accepts three box-model keyword values that define the mask positioning area.
Value
Example
Meaning
border-box
mask-origin: border-box;
The mask image is positioned relative to the border box (default).
padding-box
mask-origin: padding-box;
The mask image is positioned relative to the padding box, inside the border.
content-box
mask-origin: content-box;
The mask image is positioned relative to the content box only.
initial
mask-origin: initial;
Resets to the default value (border-box)
inherit
mask-origin: inherit;
Inherits the mask origin from the parent element
border-boxpadding-boxcontent-box
Default
🎯 Default Value
The default value of the mask-origin property is border-box, which means the mask image is positioned relative to the border box of the element by default.
Box Model
Positioning Areas
Value
Positioning starts at
Best for
border-box
Outer edge of the border
Default behavior; mask spans the full element including border
padding-box
Outer edge of the padding (inside border)
Mask aligned inside the border, like the reference example
content-box
Inner edge of the padding
Mask confined to the content area only
Preview
👀 Live Preview
The same gradient and PNG mask with three origin values — notice how the mask shifts relative to the border and padding:
border-box
padding-box
content-box
Hands-On
Examples Gallery
Apply a mask image and use mask-origin to control where the mask positioning area begins — then compare all three box values side by side.
🖼 Mask Origins
Start with the reference example — position the mask relative to the padding box instead of the default border box.
Example 1 — padding-box Origin
Apply a mask image and set mask-origin: padding-box so the mask is positioned relative to the padding area, inside the border.
The mask image is positioned relative to the padding box rather than the default border box. With visible border and padding, the mask sits inset from the outer border edge.
Example 2 — border-box (Default)
The default border-box value positions the mask relative to the outer edge of the border — the full element box including border area.
Because this is the default, you often do not need to set it explicitly. The mask positioning area starts at the outer border edge, so the mask can extend into the border region.
🛠 Content Box & Comparison
Confine the mask to the content area and compare all three origin values together.
Example 3 — content-box Origin
Use mask-origin: content-box when the mask should align only with the inner content area, excluding padding and border.
The mask positioning area is the content box only. Padding and border sit outside the mask origin, so the mask appears further inset than with padding-box or border-box.
Example 4 — All Three Origins Compared
Side-by-side comparison of border-box, padding-box, and content-box with the same mask and visible border:
Each box shifts the mask origin inward. With mask-position: top left, the mask anchor moves further right and down as you go from border-box to content-box.
A11y
♿ Accessibility
Set mask-image first — mask-origin has no effect without an active mask layer.
Do not hide essential content — Masked-away text or controls may be invisible but still exist in the DOM.
Test with visible padding — Add border and padding to see how each origin value shifts the mask.
Check contrast — Partially masked areas can reduce readability if text sits over them.
Offer fallbacks — Ensure content remains usable when masking is unsupported.
Pick border-box, padding-box, or content-box for the positioning area.
Origin selection
3
Browser positions the mask
mask-size and mask-position are calculated from the chosen box edge.
Box mapping
=
🖼
Precisely placed mask
The mask aligns to the border, padding, or content edge you specified.
Compatibility
🖥 Browser Compatibility
The mask-origin property is supported in most modern browsers, including Chrome, Firefox, Safari, and Edge. Include -webkit-mask-origin for Safari, and test with border and padding to verify positioning.
✓ Baseline · Modern browsers
Mask origin in modern browsers
All three box values work in major browsers. Use the WebKit prefix for best Safari coverage.
95%Modern browser support
Google Chrome55+ · Desktop & Mobile
Full support
Mozilla Firefox54+ · Desktop & Mobile
Full support
Apple Safari9.1+ · macOS & iOS
Full support
Microsoft Edge79+ · Chromium
Full support
Opera42+ · Modern versions
Full support
mask-origin property90% supported
Bottom line: Safe for modern projects. Pair mask-origin with -webkit-mask-origin and test PNG masks in Safari.
Wrap Up
🎉 Conclusion
The mask-origin property is a valuable tool for web developers looking to control the positioning of mask images in relation to an element’s boxes.
By understanding and using this property, you can create more precise and visually appealing designs. Experiment with different values and see how they affect the appearance of your masked elements.
Forget WebKit prefixes when targeting Safari users
Expect visible shifts without padding or border on the element
Summary
Key Takeaways
Knowledge Unlocked
Five things to remember about mask-origin
Use these points when choosing the mask positioning area.
5
Core concepts
🖼01
border-box
Default origin.
Default
⚙02
padding-box
Inside border.
Common
box03
content-box
Inner content only.
Precise
img04
Needs mask-image
Requires a mask layer.
Dependency
web05
WebKit prefix
Safari support.
Compat
❓ Frequently Asked Questions
The mask-origin property defines the positioning area for a mask image. It controls whether the mask is positioned relative to the border box, padding box, or content box of an element.
The default value is border-box, meaning the mask image is positioned relative to the outer edge of the element's border by default.
They work the same way but apply to different layers. mask-origin sets the positioning area for mask-image, while background-origin sets it for background-image.
No. mask-origin only affects how an existing mask-image is positioned. You must set mask-image first.
Use content-box when you want the mask aligned to the inner content area, ignoring padding and border — useful when padding should stay fully visible outside the mask.