CSS Portal

CSS mask-border-source Property

If this site has been useful, we’d love your support! Consider buying us a coffee to keep things going strong!

Description

The mask-border-source property specifies the image or paint used specifically for an element’s border mask — in other words, the visual source that will be sliced, stretched, and composited to form a mask that affects only the border region of the box. Unlike a plain mask that applies across the whole box, the value provided by this property is intended to be interpreted like a nine‑patch or “border” image: corners, edges, and the center are conceptually separated so the border can maintain consistent corner shapes while edges tile or stretch as needed. It is commonly used together with the shorthand mask-border, which collects the source together with the other mask-border settings.

When a source is applied via mask-border-source, user agents treat it as the painting to be cut into regions by the corresponding slice and width controls. Those regions determine which parts of the source map to the element’s corners, edges, and (optionally) the middle. How those slices are distributed and scaled is governed by related properties such as mask-border-slice, which defines where the image is partitioned; mask-border-width, which sets how much space the border occupies on the element; and mask-border-repeat, which governs whether edge regions repeat, round, or stretch. Together these properties let you control whether corners stay pixel-perfect or whether the edge artwork repeats to preserve visual rhythm.

Rendering-wise, the image provided by this property becomes a mask — its alpha (and in some cases luminance, depending on the overall mask model) determines the transparency of the element’s border area. That mask is combined with any other masks an element might have, such as those set by the global mask shorthand or by mask-image, following the compositing and stacking rules for CSS masks. Because the border mask only affects the border region, backgrounds and content inside the padding box are not directly masked by it unless additional masks are present or the same source is used elsewhere.

Practically, authors use mask-border-source to create ornate frame effects, soft or feathered edges around borders, or complex cutouts that follow the border shape without altering interior content. For best results and predictable scaling, vector sources (SVG) or high-resolution bitmaps are often preferred so that corners remain sharp at different device pixel ratios. Keep in mind performance and accessibility: using large or many externally fetched images for mask borders can increase paint costs, and masks should not be relied upon to convey essential information unless equivalent non-masked alternatives are provided.

Definition

Initial value
none
Applies to
all elements; In SVG, it applies to container elements excluding the <defs> element and all graphics elements
Inherited
no
Computed value
as specified, but with <url> values made absolute
Animatable
yes
JavaScript syntax
object.style.maskBorderSource

Syntax

mask-border-source: <image> | none;

Values

  • <image>This can be any CSS <image> value, such as a URL to an image, a gradient, or a repeating-linear-gradient, etc.
  • noneNo mask border is applied.

Example

<div class='wrap'>
<div class='card'>
<h1>mask-border-source</h1>
<p>This card uses an SVG mask image to create a decorative border. The transparent center lets the card background show through.</p>
</div>
</div>
body {
  font-family: system-ui, -apple-system, 'Segoe UI', Roboto, 'Helvetica Neue', Arial;
  background: linear-gradient(180deg, #f5f7fa 0%, #e8eef8 100%);
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 32px;
}

.wrap {
  max-width: 420px;
  width: 100%;
}

.card {
  position: relative;
  padding: 28px;
  color: #0f172a;
  background: linear-gradient(135deg, rgba(255,255,255,0.85), rgba(255,255,255,0.7));
  border-radius: 12px;

  /* SVG used as a mask for the border */
  -webkit-mask-border-source: url('data:image/svg+xml;utf8,');
  mask-border-source: url('data:image/svg+xml;utf8,');

  -webkit-mask-border-slice: 30 fill;
  mask-border-slice: 30 fill;

  -webkit-mask-border-width: 18px;
  mask-border-width: 18px;

  -webkit-mask-border-repeat: stretch;
  mask-border-repeat: stretch;
}

.card h1 {
  margin: 0 0 8px 0;
  font-size: 1.25rem;
}

.card p {
  margin: 0;
  font-size: 0.95rem;
  line-height: 1.4;
  color: #16324b;
}

Browser Support

The following information will show you the current browser support for the CSS mask-border-source property. Hover over a browser icon to see the version that first introduced support for this CSS property.

This property is supported in some modern browsers, but not all.
Desktop
Chrome
Edge
Firefox
Opera
Safari
Tablets & Mobile
Chrome Android
Firefox Android
Opera Android
Safari iOS
Samsung Internet
Android WebView
-

Last updated by CSSPortal on: 1st January 2026

If this site has been useful, we’d love your support! Consider buying us a coffee to keep things going strong!