Knowledge baseExam Center
ENEnglish
Choose language13

CKTIS / CSS

mask-repeat — tiling a mask image

The mask-repeat property controls whether and how a mask image repeats horizontally and vertically. Use it to display a single mask, create regular tiles, or adjust tile spacing or size.

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

Syntax

mask-repeat: <repeat-style>#;
<repeat-style> = repeat-x | repeat-y | [ repeat | space | round | no-repeat ]{1,2}

mask-repeat controls the tiling of mask images after their size and position are established. Its initial value is repeat; it is not inherited, and its animation is discrete. mask-image supplies the image, mask-size sets the tile size, and mask-position sets its position.

One value from repeat, space, round, and no-repeat applies to both axes. With two values, the first controls the horizontal axis and the second the vertical axis. repeat-x means repeat no-repeat, and repeat-y means no-repeat repeat. repeat tiles the image, potentially clipping edge tiles; no-repeat displays one copy along that axis.

space fits as many whole tiles as possible without scaling and distributes leftover space between them. When at least two fit, the outermost tiles touch the positioning area's edges; when only one fits, mask-position matters. round scales tiles so that a whole number fits.

Commas separate settings for successive mask-image layers; a list that is too short repeats. The property has no effect on a layer referencing an SVG mask element. In the example, each tile's transparent half hides the element, revealing the white page.

Examples

<!doctype html>
<meta charset="utf-8">
<title>mask-repeat</title>
<style>
  body { background: white; }
  .sample {
    width: 160px;
    height: 80px;
    background: #0066cc;
    mask-image: linear-gradient(to right, black 50%, transparent 50%);
    mask-mode: alpha;
    mask-size: 40px 80px;
    mask-position: 0 0;
    mask-repeat: repeat-x;
  }
</style>
<div class="sample"></div>

Result

Four blue vertical stripes, each 20 CSS px wide and 80 CSS px high, separated by 20 CSS px transparent gaps showing the white page.

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