Skip to main content

CSS Mask Image Generator

Build mask-image CSS the visual way: linear, radial & conic gradient masks, image masks and SVG masks — with a live preview and copy-ready output that always ships the -webkit- prefix Safari needs.

5 mask types 9 worked examples -webkit- prefix included 100% client-side

01 Choose a mask type

Linear gradient mask

deg

Double edge fades both ends — ideal for scroll rows and marquees.

How much of the element stays fully visible before the fade starts.

02 Live preview

The mask is applied live to this box — what you see is exactly what the CSS does.

03 Copy-ready CSS


    

04 Worked examples — copy-paste CSS mask snippets

Every snippet below was generated by this page's own engine — click Load in generator to tweak it live.

Fade bottom

Image dissolving into the page background — the classic hero fade.

.masked {
  mask-image: linear-gradient(to bottom, black 60%, transparent 100%);
  -webkit-mask-image: linear-gradient(to bottom, black 60%, transparent 100%);
}

Double-edge marquee

Horizontal scroll row fading at both ends.

.masked {
  mask-image: linear-gradient(to right, transparent 0%, black 15%, black 85%, transparent 100%);
  -webkit-mask-image: linear-gradient(to right, transparent 0%, black 15%, black 85%, transparent 100%);
}

Vignette

Soft dark-edge photo vignette with a radial ellipse mask.

.masked {
  mask-image: radial-gradient(ellipse 70% 70% at center, black 55%, transparent 100%);
  -webkit-mask-image: radial-gradient(ellipse 70% 70% at center, black 55%, transparent 100%);
}

Spotlight

Circular reveal — content visible only inside the spotlight.

.masked {
  mask-image: radial-gradient(circle 45% at center, black 40%, transparent 100%);
  -webkit-mask-image: radial-gradient(circle 45% at center, black 40%, transparent 100%);
}

Diagonal wipe

135° linear wipe for section transitions.

.masked {
  mask-image: linear-gradient(135deg, black 50%, transparent 100%);
  -webkit-mask-image: linear-gradient(135deg, black 50%, transparent 100%);
}

Read-more text fade

Truncated article preview fading out at the bottom.

.masked {
  mask-image: linear-gradient(to bottom, black 72%, transparent 100%);
  -webkit-mask-image: linear-gradient(to bottom, black 72%, transparent 100%);
}

Image mask (alpha PNG)

Mask with a real image file — alpha channel cuts the shape.

.masked {
  mask-image: url('https://example.com/logo-alpha.png');
  -webkit-mask-image: url('https://example.com/logo-alpha.png');
  mask-size: cover;
  -webkit-mask-size: cover;
  mask-repeat: no-repeat;
  -webkit-mask-repeat: no-repeat;
  mask-position: center;
  -webkit-mask-position: center;
}

SVG star mask

Crisp vector star via data URI — no extra HTTP request.

.masked {
  mask-image: url("data:image/svg+xml,%3Csvg%20xmlns%3D'http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg'%20viewBox%3D'0%200%20100%20100'%3E%3Cpolygon%20points%3D'50%2C5%2061%2C38%2095%2C38%2068%2C59%2079%2C93%2050%2C72%2021%2C93%2032%2C59%205%2C38%2039%2C38'%20fill%3D'black'%2F%3E%3C%2Fsvg%3E");
  -webkit-mask-image: url("data:image/svg+xml,%3Csvg%20xmlns%3D'http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg'%20viewBox%3D'0%200%20100%20100'%3E%3Cpolygon%20points%3D'50%2C5%2061%2C38%2095%2C38%2068%2C59%2079%2C93%2050%2C72%2021%2C93%2032%2C59%205%2C38%2039%2C38'%20fill%3D'black'%2F%3E%3C%2Fsvg%3E");
  mask-size: contain;
  -webkit-mask-size: contain;
  mask-repeat: no-repeat;
  -webkit-mask-repeat: no-repeat;
  mask-position: center;
  -webkit-mask-position: center;
}

Conic sweep

Radial sweep reveal, great for progress and loading effects.

.masked {
  mask-image: conic-gradient(from 0deg at center, black 75%, transparent 100%);
  -webkit-mask-image: conic-gradient(from 0deg at center, black 75%, transparent 100%);
}

05 mask-image vs clip-path: when to use which

Both cut content into shapes, but they solve different problems. clip-path draws a hard vector outline — circle(), ellipse(), polygon() — with razor-sharp edges and zero partial transparency. mask-image works per pixel with an alpha value, so it adds everything clip-path cannot do: gradient fades, vignettes, feathered edges, and textured reveals from images or SVG.

clip-pathmask-image
Edge styleHard, anti-aliased onlySoft — full alpha control
GradientsNoYes — fades & vignettes
Image / SVG sourceNoYes, via url()
Partial transparencyNoYes, per pixel
AnimatableYes (same shape type)Yes (gradient stops, position)

06 Browser support for CSS masks

CSS masking works in all current browsers. The one rule that still bites in 2026: Safari (and older Chromium) only honor the -webkit- prefixed properties — the unprefixed mask-image alone silently does nothing there. Always ship both declarations with identical values, exactly as this generator outputs.

Browsermask-imageNotes
Chrome / EdgeYesUnprefixed since Chrome 120; use -webkit- for older versions
FirefoxYesUnprefixed for years
SafariYes, prefixedStill needs -webkit-mask-image in most versions

07 Combining masks with mask-composite

List several sources in mask-image and mask-composite decides how the layers merge: add, subtract, intersect or exclude. This vignette-plus-fade keeps only pixels visible in both gradients:

.vignette-fade {
  mask-image: linear-gradient(to bottom, black 70%, transparent),
              radial-gradient(ellipse 70% 70% at center, black 55%, transparent);
  -webkit-mask-image: linear-gradient(to bottom, black 70%, transparent),
              radial-gradient(ellipse 70% 70% at center, black 55%, transparent);
  mask-composite: intersect;
  -webkit-mask-composite: source-in;
}

Safari's -webkit-mask-composite uses different keywords — source-in is the equivalent of intersect.

08 Frequently asked questions

What is CSS mask-image and how does it work?

mask-image controls the per-pixel visibility of an element using the alpha channel of a mask source: fully opaque mask pixels keep the content visible, fully transparent pixels hide it, and anything in between fades proportionally. A gradient mask therefore creates soft fades (for example an image dissolving into the page background), while an image or SVG mask can cut content into any shape. Unlike opacity, which dims the whole element uniformly, a mask makes visibility itself vary across the element.

What is the difference between mask-image and clip-path?

clip-path cuts an element into a hard vector shape — circle(), ellipse(), polygon() — with razor-sharp edges and no partial transparency. mask-image does everything clip-path does and more: it supports gradients for soft feathered edges, image and SVG masks for complex shapes, and per-pixel alpha so parts of the element can be semi-transparent. Use clip-path for crisp geometric cutouts; use mask-image whenever you need fades, vignettes, or textured reveals.

Why does the generated CSS include -webkit-mask-image?

Safari and older Chromium-based browsers only recognize the prefixed property: the unprefixed mask-image alone silently does nothing there, so the mask appears to be broken. Current Chrome, Edge and Firefox accept the standard unprefixed form. Shipping both declarations with identical values covers every modern browser, which is why this generator always emits the -webkit- line alongside mask-image (and the same pairing for mask-size, mask-repeat and mask-position).

Which browsers support CSS mask-image?

All current browsers support CSS masking: Chrome and Edge (unprefixed since Chrome 120, prefixed before that), Firefox (unprefixed for years), and Safari (still needs the -webkit- prefix in most versions, so always ship both). Gradients as mask sources work everywhere masking does. The advanced mask-composite property is spottier: the standard keywords add, subtract, intersect and exclude work in Chrome, Edge and Firefox, while Safari uses -webkit-mask-composite with a different keyword set (source-in is the equivalent of intersect).

Can I use an image or an SVG as a CSS mask?

Yes. mask-image accepts any image source via url(): a PNG with an alpha channel masks by transparency, and an SVG masks by its shapes' alpha. Pair it with mask-size (cover, contain or explicit dimensions), mask-repeat (usually no-repeat) and mask-position to place the mask exactly. An SVG can also be inlined as a data URI — url("data:image/svg+xml,...") — which avoids an extra HTTP request; this generator builds that data URI for you from five built-in shapes or your own SVG markup.

What is mask-composite and when do I need it?

mask-composite controls how multiple mask layers combine when you list more than one source in mask-image. The standard keywords are add (union), subtract (cut the second out of the first), intersect (keep only the overlap) and exclude (keep the non-overlapping parts). A classic use is a vignette plus a bottom fade: mask-image takes both gradients and mask-composite: intersect keeps only pixels visible in both. Note Safari's -webkit-mask-composite uses different keywords — source-in is the equivalent of intersect.

Is my input sent to a server?

No. This page runs 100 percent in your browser: the mask CSS engine is plain JavaScript with no network requests, no cookies and no analytics on your input. You can disconnect from the internet and it keeps working. Nothing you type or paste ever leaves your device.

Free tool by NRTechStudio