CSS mask-position Property

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

Definition and Usage

The mask-position property sets the starting place of each mask-image inside the area chosen by mask-origin. One value, two values, or a four-value edge offset can place the mask. With several mask layers, list positions with commas in the same order.

The initial value is 0% 0% (top left). The property is not inherited. Pair it with mask-repeat: no-repeat and a fixed mask-size when you want to see one placed mask instead of a tile.

Standard-track.

Not deprecated and not experimental. Unprefixed mask-position is Baseline widely available. Older Safari needed -webkit-mask-position. Unlike background-position, there is no three-value syntax.

CSS Syntax

syntax.css
mask-position: center | top left | 25% 75% | 20px 30px | bottom 10px right 20px | initial | inherit;

One value implies center for the other axis. With two lengths or percentages, the first is horizontal and the second is vertical. Separate multiple mask layers with commas.

Property Values

ValueDescriptionTry it
centerCenters the mask in both axes. One keyword alone centers the other axisTry it
top left right bottomEdge keywords. Combine two, such as top left or bottom rightTry it
25% 75%Percentage offsets. First is horizontal, second is verticalTry it
20px 30pxLength offsets from the top-left of the positioning areaTry it
bottom 10px right 20pxEdge offsets. Each length follows the edge it offsets from. Four values requiredTry it
0 0, centerOne position per mask layer in a comma-separated listTry it
initialResets this property to 0% 0%Try it
inheritCopies this property from the parent elementTry it

How to Use mask-position

Give the element a mask, keep one copy visible, then set the position.

  1. Set a mask-image on the element. Without a mask, there is nothing to place.
  2. Give the element a visible size and a background you can see through the mask.
  3. Use mask-repeat: no-repeat and a fixed mask-size so one mask shape is easy to see.
  4. Set mask-position with a keyword, a pair of values, or a four-value edge offset. It is not inherited.
PieceRequired?Role
mask-imageYesThe image or gradient used as the mask layer
A visible boxYesContent or a height, so the position has somewhere to show
mask-positionYesKeywords, percentages, lengths, or four-value edge offsets
mask-repeatOftenno-repeat keeps a single placed mask easy to see
mask-originNoWhich box the position is measured against

Live Preview

One circular mask over a gradient. Change mask-position and watch where the revealed circle sits.

The mask does not repeat. Only its starting place changes.

Position

mask-position: center

CSS Examples

Each snippet adds only what mask-position needs: a mask, a sized box, and no-repeat so the shape is clear. Use Try It Yourself for a live editor.

Example 1 — Center the Mask

Place a single circular mask in the middle of the box.

CSS
<style>
  div {
    height: 160px;
    border: 1px solid #ccc;
    background: linear-gradient(135deg, #2563eb, #7c3aed);
    mask-image: radial-gradient(circle, #000 0 28px, transparent 29px);
    mask-repeat: no-repeat;
    mask-size: 72px 72px;
    mask-position: center;
  }
</style>

<div></div>
Try It Yourself

How It Works

  1. Make a box. height: 160px and the border give the mask a clear area to sit in.
  2. Paint through a mask. The gradient is the visible content. The radial gradient is the mask-image. Opaque mask pixels reveal the gradient.
  3. Stop the tile. mask-repeat: no-repeat and mask-size: 72px 72px show one circle. Without them, copies would fill the box and hide the placement.
  4. Center it. mask-position: center puts the mask in the middle on both axes.

Example 2 — Percentage Place

Line up a point on the mask with the same point on the box.

CSS
<style>
  div {
    height: 160px;
    border: 1px solid #ccc;
    background: linear-gradient(135deg, #059669, #0d9488);
    mask-image: radial-gradient(circle, #000 0 28px, transparent 29px);
    mask-repeat: no-repeat;
    mask-size: 72px 72px;
    mask-position: 25% 75%;
  }
</style>

<div></div>
Try It Yourself

How It Works

  1. Read left to right, then top to bottom. 25% is the horizontal place. 75% is the vertical place.
  2. Match points, not edges only. Like background-position, the point 25% across the mask meets the point 25% across the box. The same idea applies for 75% vertically.
  3. 0% and 100% are the edges. 0% 0% is top left. 100% 100% is bottom right. 50% 50% is center.
  4. Size still matters. If the mask were the same size as the box, a percentage would have no leftover space to slide. Here the circle is smaller, so the move is visible.

Example 3 — Edge Offsets

Anchor to an edge, then nudge inward with a length. Use all four values.

CSS
<style>
  div {
    height: 160px;
    border: 1px solid #ccc;
    background: linear-gradient(135deg, #ea580c, #db2777);
    mask-image: radial-gradient(circle, #000 0 28px, transparent 29px);
    mask-repeat: no-repeat;
    mask-size: 72px 72px;
    mask-position: bottom 10px right 20px;
  }
</style>

<div></div>
Try It Yourself

How It Works

  1. Name the edge first. bottom and right choose which edges the mask sits against.
  2. Offset after each edge. 10px follows bottom, so the circle lifts 10px from the bottom. 20px follows right, so it moves 20px inward from the right.
  3. Use four values. Offsetting from bottom or right needs both edge keywords and both lengths. A three-value form is invalid for mask-position.
  4. Order of the pairs can swap. right 20px bottom 10px is the same placement. Plain bottom right sticks to the corner with no inset.

Edge Cases & Pitfalls

If the mask looks stuck, tiled, or unchanged, one of these is usually why.

image

No mask-image, no movement

mask-position only places an active mask layer. Set mask-image first, or use the mask shorthand that includes one.

repeat

Tiles hide a clear placement

The initial mask-repeat is repeat. The starting place still applies, but copies fill the box. Use no-repeat when you want one mask.

size

A full-size mask ignores percentages

If mask-size matches the box on an axis, that axis has no leftover space. A percentage then looks stuck. Use a length, or make the mask smaller than the box.

syntax

No three-value form

Unlike background-position, mask-position does not allow a three-value edge offset, and you cannot offset from center. From bottom or right, declare all four values.

origin

Position is measured from mask-origin

mask-origin picks the box the position uses. The default is padding-box. Changing the origin moves the same position value relative to a different box.

Browser Support

mask-position 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-position.

✓ Baseline · Widely available since Dec 2023

mask-position

Unprefixed: Chrome 120+, Edge 120+, Firefox 53+, Safari 15.4+. Prefixed WebKit support is older. Internet Explorer has no CSS mask-position.

97% Modern browser support
Google Chrome 120+ unprefixed · older with -webkit-
Full support
Mozilla Firefox 53+
Full support
Apple Safari 15.4+ unprefixed · older with -webkit-
Full support
Microsoft Edge 120+ unprefixed
Full support
Opera 106+ unprefixed
Full support
Samsung Internet 25+ unprefixed
Full support
Internet Explorer No support
None
mask-position Widely supported

Bottom line: Safe for current browsers with the unprefixed property. Add -webkit-mask-position only if you must support older Safari or Chromium builds before the Baseline versions above. Do not treat this as a Node.js or other runtime feature.

Key Takeaways

  • Role: place each mask image inside the area from mask-origin.
  • Values: keywords, percentages, lengths, or four-value edge offsets such as bottom 10px right 20px.
  • Initial value: 0% 0% (top left). It is not inherited.
  • See it clearly: use mask-repeat: no-repeat and a fixed mask-size when a single placed mask is the goal.

One line: mask-position chooses where the mask starts — after you have a mask-image, and usually after you turn off tiling.

Frequently Asked Questions

It sets the starting place of each mask image inside the area chosen by mask-origin. Keywords, percentages, lengths, and four-value edge offsets all place that mask. The initial value is 0% 0%, which is the top-left corner.
0% 0%, the same as top left. The mask starts at the top-left of the area defined by mask-origin (padding-box by default). The property is not inherited.
No. There must be a mask-image (or a mask shorthand that sets one). Without a mask layer, changing mask-position has nothing to move.
They share the same idea and similar values: place a layer inside a box. mask-position moves the mask image. background-position moves the background image. One difference: mask-position has no three-value syntax; offsetting from bottom or right needs all four values.
mask-repeat defaults to repeat, so copies can fill the box and hide placement. Use mask-repeat: no-repeat to see one mask. If mask-size fills the box, a percentage also has no room to slide.
Unprefixed mask-position is Baseline and widely available since December 2023: Chrome 120+, Edge 120+, Firefox 53+, Safari 15.4+. Older WebKit browsers used -webkit-mask-position. Internet Explorer does not support it. This is a browser CSS property. Node.js, Deno, and Bun do not paint it.

Next: mask-repeat

Learn how to tile a mask image, or show it once with no-repeat.

mask-repeat 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.

8 people found this page helpful