The mask-position property defines where a mask-image is placed inside an element — using the same keywords, percentages, and lengths as background-position.
01
Placement
Move the mask image.
02
Keywords
top, left, center.
03
Percentages
Relative positioning.
04
Pixels
Exact distances.
05
WebKit
Prefix for Safari.
06
Related
mask-size, repeat.
Fundamentals
Introduction
The mask-position property in CSS defines the position of a mask image within an element. Masking allows you to hide or reveal specific parts of an element based on the transparency and position of the mask image.
This property is especially useful for creating complex shapes, patterns, and visual effects by positioning the mask precisely. Pair it with mask-image, mask-size, and mask-repeat for full control.
Definition and Usage
Use mask-position: center to center a silhouette mask, top left for corner placement, or percentages and pixels for fine-tuned offsets. The syntax mirrors background-position, so if you know one, the other feels familiar.
💡
Beginner Tip
Set mask-repeat: no-repeat and a fixed mask-size first — then change only mask-position to clearly see how the mask moves inside the element.
Foundation
📝 Syntax
The syntax for the mask-position property is similar to background-position. It accepts horizontal and vertical position values:
syntax.css
element{mask-position:x-position y-position;}
x-position — specifies the horizontal position of the mask image.
y-position — specifies the vertical position of the mask image.
Use keywords like center, percentages like 75% 25%, or lengths like 20px 10px.
Position values
3
Browser places the mask
The mask image is aligned within the mask positioning area defined by mask-origin and sized with mask-size.
Coordinate mapping
=
🖼
Precisely placed mask
The mask shape appears exactly where you specified, revealing or hiding the right parts of the element.
Compatibility
🖥 Browser Compatibility
The mask-position property is supported in most modern browsers, including Chrome, Firefox, Safari, Edge, and Opera. Include -webkit-mask-position for Safari, and test across browsers to ensure your mask placement looks correct.
✓ Baseline · Modern browsers
Mask position in modern browsers
Keywords, percentages, and length values all 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-position property95% supported
Bottom line: Safe for modern projects. Pair mask-position with -webkit-mask-position and test PNG masks in Safari.
Wrap Up
🎉 Conclusion
The mask-position property is a versatile tool for web designers and developers looking to create unique and visually engaging masked effects.
By controlling where the mask image sits, you can manipulate which parts of an element are visible. Experiment with keywords, percentages, and pixel values to achieve the effect you want.
Combine keywords like top left for corner alignment
Use percentages for responsive mask placement that scales with the element
Always set mask-image before applying mask-position
Include -webkit-mask-position alongside mask-position
❌ Don’t
Set mask-position without a mask-image
Confuse mask-position with mask-origin — position moves the mask; origin sets the positioning area
Hide essential text or controls with masks
Forget WebKit prefixes when targeting Safari users
Expect visible movement when mask-size: cover fills the entire area
Summary
Key Takeaways
Knowledge Unlocked
Five things to remember about mask-position
Use these points when placing a mask image on an element.
5
Core concepts
🖼01
0% 0%
Default top-left.
Default
⚙02
Keywords
center, top left.
Common
%03
Percentages
Scale with size.
Flexible
img04
Like background-position
Same syntax.
Familiar
web05
WebKit prefix
Safari support.
Compat
❓ Frequently Asked Questions
The mask-position property defines where a mask image is placed within an element. It works like background-position but applies to the mask-image layer.
The default value is 0% 0%, which places the mask image at the top-left corner of the mask positioning area.
They use the same syntax and values, but mask-position moves the mask-image layer while background-position moves the background-image layer.
No. mask-position only affects placement when a mask-image is set. You must define the mask source first.
Yes. Keywords like center, top left, and bottom right are common values, just like with background-position.