CSS mask-origin Property

Beginner
5 min read
Updated: Oct 2026
3 examples
Live preview

Definition and Usage

The mask-origin property sets the mask positioning area — the box used as the reference when placing a mask-image. Think of it as the mask version of background-origin.

It is not inherited. For HTML boxes the initial value is border-box (background-origin defaults to padding-box). You need a mask-image first.

Baseline Widely available.

Not deprecated. Prefer standard *-box keywords. Non-standard aliases content, padding, and border exist in some engines — avoid them in new code. SVG-only values (fill-box, stroke-box, view-box) map to border-box on HTML elements.

CSS Syntax

syntax.css
mask-origin: border-box | padding-box | content-box | fill-box | stroke-box | view-box | initial | inherit;

Multiple comma-separated values map to multiple mask-image layers.

Property Values

ValueDescriptionTry it
border-boxDefault. Position relative to the border edgeTry it
padding-boxPosition relative to the padding edge (inside the border)Try it
content-boxPosition relative to the content edge (inside padding)Try it
compare boxesSee border-box, padding-box, and content-box togetherTry it
initialResets to border-boxTry it
inheritTakes the parent’s mask-originTry it

How to Use mask-origin

Give the element a visible border and padding so origin shifts are easy to see.

  1. Set mask-image (and usually mask-repeat: no-repeat).
  2. Add thick border and padding so the three boxes differ.
  3. Place the mask with mask-position (for example top left).
  4. Choose border-box, padding-box, or content-box.
PieceRequired?Role
mask-imageYesThe mask layer being positioned
Border / paddingFor learningMakes origin differences obvious
mask-originOptionalPicks which box is the positioning area
mask-positionHelpfulPlaces the mask inside that area

Live Preview

A small circular mask sits at top left. Change the origin and watch which box corner it uses.

Blue = border. Space inside the border = padding. Innermost area = content.

Box

mask-origin: border-box — mask starts at the outer border edge

CSS Examples

Each snippet focuses on mask-origin. Use Try It Yourself for a live editor.

Example 1 — Border-box (Default)

Position the mask from the outer border edge.

CSS
<style>
  div {
    width: 180px;
    height: 130px;
    padding: 20px;
    border: 16px solid #2563eb;
    background: #a7f3d0;
    mask-image: radial-gradient(circle, #000 65%, transparent 66%);
    mask-size: 52px 52px;
    mask-repeat: no-repeat;
    mask-position: top left;
    mask-origin: border-box;
  }
</style>

<div></div>
Try It Yourself

How It Works

  1. Add border and padding. They create three nested boxes to measure from.
  2. Place a small mask. A circle at top left makes the origin easy to spot.
  3. Use border-box. The mask’s top-left is the outer border corner.
  4. Default behavior. Omitting mask-origin does the same thing.

Example 2 — Padding-box

Start inside the border, at the padding edge.

CSS
<style>
  div {
    width: 180px;
    height: 130px;
    padding: 20px;
    border: 16px solid #2563eb;
    background: #a7f3d0;
    mask-image: radial-gradient(circle, #000 65%, transparent 66%);
    mask-size: 52px 52px;
    mask-repeat: no-repeat;
    mask-position: top left;
    mask-origin: padding-box;
  }
</style>

<div></div>
Try It Yourself

How It Works

  1. Same mask setup. Only mask-origin changes.
  2. Padding-box origin. Top-left is inside the blue border.
  3. Border stays outside. The positioning area no longer includes the border thickness.
  4. Compare with Example 1. The circle shifts inward by the border width.

Example 3 — Content-box

Start at the content edge, past both border and padding.

CSS
<style>
  div {
    width: 180px;
    height: 130px;
    padding: 20px;
    border: 16px solid #2563eb;
    background: #a7f3d0;
    mask-image: radial-gradient(circle, #000 65%, transparent 66%);
    mask-size: 52px 52px;
    mask-repeat: no-repeat;
    mask-position: top left;
    mask-origin: content-box;
  }
</style>

<div></div>
Try It Yourself

How It Works

  1. Content-box origin. The reference is the innermost content rectangle.
  2. Inset again. The circle moves in by border + padding.
  3. Use case. Keep padding and border outside the masked region’s start point.
  4. Pair with position. mask-position still applies inside this smaller area.

Edge Cases & Pitfalls

Origin is hard to see without border, padding, and a non-repeating mask.

need

Needs mask-image

Without a mask layer, changing mask-origin has no visible effect.

repeat

A full-bleed repeating mask hides the shift

Use mask-repeat: no-repeat and a sized mask so the origin corner is obvious.

default

Default differs from background-origin

mask-origin starts at border-box; background-origin starts at padding-box.

alias

Skip non-standard shortcuts

border, padding, and content are non-standard aliases. Prefer border-box, padding-box, and content-box.

Browser Support

mask-origin is a browser CSS property. Node.js, Deno, and Bun do not apply it.

✓ Baseline · Widely available since Dec 2023

mask-origin

Chrome 120+, Edge 120+, Firefox 53+, Safari 15.4+, Opera 106+. Use standard *-box keywords. Internet Explorer has no support.

97% Global reach
Google Chrome 120+
Full support
Mozilla Firefox 53+
Full support
Apple Safari 15.4+
Full support
Microsoft Edge 120+
Full support
Opera 106+
Full support
Samsung Internet 25.0+
Full support
Internet Explorer No support
Not supported
mask-origin Widely supported

Bottom line: Safe for modern sites with standard border-box / padding-box / content-box values. Not a server runtime API.

Key Takeaways

  • Role: choose which box is the mask positioning area.
  • Common values: border-box, padding-box, content-box.
  • Initial value: border-box. Not inherited.
  • Tip: thick border + padding + a small no-repeat mask makes the effect obvious.

One line: mask-origin picks the box that mask-position measures from.

Frequently Asked Questions

It sets the mask positioning area — the box used as the reference when placing mask-image. Common choices are border-box, padding-box, and content-box.
For HTML elements with a CSS layout box, the initial value is border-box.
They work the same idea on different layers. mask-origin defaults to border-box; background-origin defaults to padding-box.
No. It only changes where an existing mask-image is positioned. Set mask-image first.
Use content-box when the mask should start from the content edge, ignoring padding and border thickness.
It is Baseline and widely available since December 2023: Chrome 120+, Edge 120+, Firefox 53+, Safari 15.4+. Prefer standard *-box keywords over non-standard content/padding/border aliases. Internet Explorer does not support it. It is a browser CSS property, not a Node.js feature.

Next: mask-position

Learn how to place the mask inside the origin area.

mask-position tutorial →

About the author

Mari Selvan M P
Mari Selvan M P 🔗

Developer, cloud engineer, and technical writer

  • Experience 12 years building web and cloud systems
  • Focus Full Stack Development, AWS, and Developer Education

I write practical tutorials so students and working developers can learn by doing—from databases and APIs to deployment on AWS.

5 people found this page helpful