CSS mask-repeat Property

Beginner
⏱️ 7 min read
📚 Updated: Jun 2026
🎯 4 Examples
Visual Effects

What You’ll Learn

The mask-repeat property controls how a mask-image tiles across an element — using the same keywords as background-repeat.

01

Tiling

Tile the mask image.

02

repeat

Default both axes.

03

no-repeat

Single mask shape.

04

repeat-x / y

One-axis tiling.

05

WebKit

Prefix for Safari.

06

Related

mask-size, position.

Introduction

The mask-repeat property in CSS defines how a mask image is repeated (tiled) across an element. This property lets you control the repetition behavior of the mask image, which can enhance the visual presentation of your web elements.

Masking is commonly used to create complex shapes, gradients, and patterns by overlaying an image that determines the visibility of different parts of the element. Pair it with mask-image, mask-size, and mask-position for full control.

Definition and Usage

Use mask-repeat: repeat (the default) to tile a small mask into a pattern, no-repeat for a single silhouette, or repeat-x / repeat-y to tile along one axis only. The syntax mirrors background-repeat, so if you know one, the other feels familiar.

💡
Beginner Tip

Set a small mask-size (like 48px) first — then change only mask-repeat to clearly see how tiling differs from a single mask shape.

📝 Syntax

The syntax for the mask-repeat property can accept one or two values, representing the horizontal and vertical repeat behavior:

syntax.css
element {
  mask-repeat: value;
}

Basic Example

mask-repeat.css
.masked {
  width: 300px;
  height: 300px;
  background: url('/images/valley-pattern.jpg') center/cover;
  -webkit-mask-image: url('/images/apple.png');
  mask-image: url('/images/apple.png');
  -webkit-mask-size: 48px;
  mask-size: 48px;
  -webkit-mask-repeat: repeat;
  mask-repeat: repeat;
}

Syntax Rules

  • The initial value is repeat (tiles both horizontally and vertically).
  • mask-repeat only applies when a mask-image is set.
  • Keywords include repeat, repeat-x, repeat-y, no-repeat, space, and round.
  • Two values can set horizontal and vertical repeat independently (e.g. repeat no-repeat).
  • Include -webkit-mask-repeat alongside mask-repeat for broader Safari support.

⚡ Quick Reference

QuestionAnswer
Initial valuerepeat
Applies toAll elements
InheritedNo
AnimatableNo
Common usePattern masks, single silhouettes, horizontal or vertical stripes

💎 Property Values

The mask-repeat property accepts the same keyword values as background-repeat.

ValueExampleMeaning
repeatmask-repeat: repeat;Tiles the mask image horizontally and vertically.
repeat-xmask-repeat: repeat-x;Tiles the mask image only horizontally.
repeat-ymask-repeat: repeat-y;Tiles the mask image only vertically.
no-repeatmask-repeat: no-repeat;The mask image is not tiled — shown once.
spacemask-repeat: space;Distributes mask images with extra space, without clipping.
roundmask-repeat: round;Scales and repeats the mask to fit without clipping.
initialmask-repeat: initial;Resets to the default value (repeat)
inheritmask-repeat: inherit;Inherits the mask repeat from the parent element
repeat no-repeat repeat-x repeat-y

🎯 Default Value

The default value of the mask-repeat property is repeat, meaning the mask image will be tiled both horizontally and vertically by default.

Common Repeat Values

ValueExampleBest for
repeatDefault tilingRepeating pattern masks across the whole element
no-repeatSingle maskLogo silhouettes and one-off decorative cutouts
repeat-xHorizontal stripRow of repeated mask shapes
repeat-yVertical stripColumn of repeated mask shapes

👀 Live Preview

The same gradient and PNG mask at 40px size — only the repeat behavior changes:

repeat
no-repeat
repeat-x

Use a small mask-size so tiling differences are easy to spot.

Examples Gallery

Tile a mask into a pattern, show a single silhouette, tile horizontally, and compare multiple repeat values side by side.

🖼 Mask Tiling

Start with the reference example — tile a mask image across the element.

Example 1 — Repeating Mask Pattern

Tile a mask image across an element with mask-repeat: repeat (the default).

mask-repeat.html
<style>
  .masked {
    width: 300px;
    height: 300px;
    background: url('/images/valley-pattern.jpg') center/cover;
    -webkit-mask-image: url('/images/apple.png');
    mask-image: url('/images/apple.png');
    -webkit-mask-size: 48px;
    mask-size: 48px;
    -webkit-mask-repeat: repeat;
    mask-repeat: repeat;
  }
</style>

<div class="masked"></div>
Try It Yourself

How It Works

mask-repeat: repeat tiles the mask in both directions. Use a small mask-size to create a visible repeating pattern.

Example 2 — Single Mask (no-repeat)

Show the mask image once without tiling using mask-repeat: no-repeat.

mask-repeat-no-repeat.html
<style>
  .mask-single {
    width: 280px;
    height: 200px;
    background: linear-gradient(135deg, #6366f1, #8b5cf6);
    -webkit-mask-image: url('/images/apple.png');
    mask-image: url('/images/apple.png');
    -webkit-mask-size: contain;
    mask-size: contain;
    -webkit-mask-repeat: no-repeat;
    mask-repeat: no-repeat;
    -webkit-mask-position: center;
    mask-position: center;
  }
</style>

<div class="mask-single"></div>
Try It Yourself

How It Works

no-repeat is the go-to choice for a single logo or silhouette mask. Pair it with mask-position: center to center the shape.

🛠 Axis Tiling & Comparison

Tile along one axis, then compare multiple repeat values.

Example 3 — Horizontal Repeat (repeat-x)

Tile the mask only horizontally with mask-repeat: repeat-x — useful for row patterns and decorative strips.

mask-repeat-x.html
<style>
  .mask-row {
    width: 280px;
    height: 200px;
    background: url('/images/valley-pattern.jpg') center/cover;
    -webkit-mask-image: url('/images/apple.png');
    mask-image: url('/images/apple.png');
    -webkit-mask-size: 48px;
    mask-size: 48px;
    -webkit-mask-repeat: repeat-x;
    mask-repeat: repeat-x;
  }
</style>

<div class="mask-row"></div>
Try It Yourself

How It Works

repeat-x tiles the mask left to right only. Use repeat-y for vertical columns of the same shape.

Example 4 — Repeat Values Compared

Side-by-side comparison of repeat, no-repeat, and repeat-x with the same mask:

mask-repeat-compare.css
.mask-box {
  width: 200px;
  height: 140px;
  background: linear-gradient(135deg, #f97316, #ec4899);
  -webkit-mask-image: url('/images/apple.png');
  mask-image: url('/images/apple.png');
  -webkit-mask-size: 40px;
  mask-size: 40px;
}
.rpt-repeat { mask-repeat: repeat; }
.rpt-none { mask-repeat: no-repeat; mask-position: center; }
.rpt-x { mask-repeat: repeat-x; }
Try It Yourself

How It Works

With the same mask size and image, changing only mask-repeat switches between a full pattern, a single shape, and a horizontal row.

♿ Accessibility

  • Set mask-image firstmask-repeat has no effect without an active mask layer.
  • Do not hide essential content — Masked-away text or controls may be invisible but still exist in the DOM.
  • Test with small mask-size — Use a small tile size so repeat patterns are visible and easy to evaluate.
  • Check contrast — Partially masked areas can reduce readability if text sits over them.
  • Offer fallbacks — Ensure content remains usable when masking is unsupported.

mask-repeat vs background-repeat

Featuremask-repeatbackground-repeat
ControlsHow the mask image tiles within the mask areaHow the background image tiles within the background area
Default valuerepeatrepeat
Valuesrepeat, repeat-x, repeat-y, no-repeat, space, roundrepeat, repeat-x, repeat-y, no-repeat, space, round
Typical usePattern masks or single silhouette cutoutsDecorative background textures and images

🧠 How mask-repeat Works

1

You set a mask-image

Define the mask source with mask-image first.

Mask source
2

You choose repeat behavior

Pick repeat, no-repeat, repeat-x, or repeat-y to control tiling.

Repeat values
3

Browser tiles the mask

The mask image repeats according to your value, sized by mask-size and positioned with mask-position.

Tiling logic
=

Pattern or single mask

The element shows a repeating pattern or a single masked shape, depending on the repeat value you chose.

🖥 Browser Compatibility

The mask-repeat property is supported in most modern browsers, including Chrome, Firefox, Safari, Edge, and Opera. Include -webkit-mask-repeat for Safari, and test across browsers to ensure your mask tiling looks correct.

Baseline · Modern browsers

Mask repeat in modern browsers

All standard repeat keywords work in major browsers. Use the WebKit prefix for best Safari coverage.

95% Modern browser support
Google Chrome 55+ · Desktop & Mobile
Full support
Mozilla Firefox 54+ · Desktop & Mobile
Full support
Apple Safari 9.1+ · macOS & iOS
Full support
Microsoft Edge 79+ · Chromium
Full support
Opera 42+ · Modern versions
Full support
mask-repeat property 95% supported

Bottom line: Safe for modern projects. Pair mask-repeat with -webkit-mask-repeat and test PNG masks in Safari.

🎉 Conclusion

The mask-repeat property is a versatile tool for web designers looking to create visually compelling effects using mask images.

By controlling how the mask image tiles, you can add depth and style to your web elements. Experiment with repeat, no-repeat, and axis-specific values to achieve the effect you want.

💡 Best Practices

✅ Do

  • Use repeat for repeating pattern masks across an element
  • Use no-repeat for a single logo or silhouette mask
  • Use repeat-x or repeat-y for one-axis strip patterns
  • Always set mask-image before applying mask-repeat
  • Include -webkit-mask-repeat alongside mask-repeat

❌ Don’t

  • Set mask-repeat without a mask-image
  • Confuse mask-repeat with mask-size — repeat controls tiling; size controls tile dimensions
  • Hide essential text or controls with masks
  • Forget WebKit prefixes when targeting Safari users
  • Expect visible tiling when mask-size: cover fills the entire area

Key Takeaways

Knowledge Unlocked

Five things to remember about mask-repeat

Use these points when tiling a mask image on an element.

5
Core concepts
02

no-repeat

Single mask.

Common
03

repeat-x / y

One-axis tiles.

Patterns
img 04

Like background-repeat

Same keywords.

Familiar
web 05

WebKit prefix

Safari support.

Compat

❓ Frequently Asked Questions

The mask-repeat property defines how a mask image is repeated (tiled) across an element. It works like background-repeat but applies to the mask-image layer.
The default value is repeat, which tiles the mask image both horizontally and vertically across the element.
They accept the same keyword values, but mask-repeat controls tiling of the mask-image layer while background-repeat controls the background-image layer.
No. mask-repeat only affects how a mask tiles when a mask-image is set. You must define the mask source first.
Use no-repeat when you want a single mask shape — such as a logo silhouette or one decorative cutout — instead of a repeating pattern.

Practice in the Live Editor

Open the HTML editor, try mask-repeat with repeat, no-repeat, and repeat-x values, and preview effects instantly.

HTML Editor →

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