Knowledge baseExam Center
ENEnglish
Choose language13

CKTIS / CSS

mask-position — positioning a mask image

The mask-position property places the image of each mask layer. It accepts keywords, lengths, and percentages; it does not move the element itself or change its layout.

Version: CSS modules; structured CSSWG indexes reconciled with pinned MDN BCD; Chromium 152 scope gate, per-example verification still required

Syntax

mask-position: <position>#;

mask-position positions mask images relative to the area established by mask-origin. Its initial value is 0% 0%, and it is not inherited. The grammar <position># means a comma-separated list of positions assigned to successive mask-image layers.

Values include center, left top, 20px 10px, and right 20px bottom 10px. With two lengths, the first specifies the horizontal offset and the second the vertical offset. A single value such as left leaves the other axis centered. Percentages align corresponding points of the image and positioning area: 50% 50% centers the image. The offset on each axis is (area size - image size) × percentage; equal sizes mean percentages produce no movement.

mask-size sets the image dimensions, while mask-repeat controls repetition. In the example, no-repeat exposes a single mask rectangle. Masking changes visibility, not the layout box dimensions. When mask-image references an SVG mask element, mask-position has no effect on that layer.

Examples

<!doctype html>
<meta charset="utf-8">
<title>mask-position</title>
<style>
  body { margin: 0; background: white; }
  .sample {
    width: 200px;
    height: 120px;
    background: #0066cc;
    mask-image: linear-gradient(black, black);
    mask-mode: alpha;
    mask-origin: border-box;
    mask-clip: border-box;
    mask-size: 80px 40px;
    mask-repeat: no-repeat;
    mask-position: right 20px bottom 10px;
  }
</style>
<div class="sample"></div>

Result

Expected visual geometry in CSS pixels: a blue 80 × 40 rectangle with its top-left corner at (100, 70), on a white page. The element retains its 200 × 120 layout box.

The displayed code and declared result were verified in an isolated environment using the method recorded in the verification evidence for this exact version.

Sources