CSS mask-border-slice Property
Description
The mask-border-slice property controls how the image used for a mask border is divided into regions that supply the visual (alpha) parts used to form an element’s masked border. It defines inward offsets from the image edges that create the four corner pieces, four edge strips, and the central area. Those slices determine which parts of the source image become the corners and edges of the mask and therefore how the mask will be mapped onto the element’s box.
Slicing affects more than just which pixels are used - it influences how those pixels are treated when the mask is applied. Corners are typically preserved as discrete pieces while edge strips are candidates for stretching or tiling along the corresponding sides; the center region can either contribute to filling the interior or be effectively ignored depending on the mask fill behavior. This behavior is conceptually similar to how border-image-slice divides border images for drawing decorative borders, but in this case the divided parts form an alpha mask that shapes transparency and hit-testing rather than painting color.
mask-border-slice is normally used together with the other mask-border-related settings so that the chosen slices map correctly to the supplied image and the desired repeat/stretch behavior. The overall result depends on the image source and how the mask is composed, so it’s helpful to think of slices as a way to say “which parts of the image are corners, which are edges, and which is the center” while leaving the actual image selection and compositing to the companion properties such as mask-border and the more general masking image controls like mask-image. Changing the slice values can therefore dramatically change the appearance and interactive clipping of the masked element without altering the source image itself.
In practical terms, designers use mask-border-slice to preserve decorative corner art from distortion, to control which parts of a mask repeat along edges, and to decide whether the central part of a mask should act as a filled interior. Because the property only governs the geometry of the split, the final visual effect is the combination of the slices, the mask image content, and the neighboring mask-border properties that specify source, repeat, and compositing behavior.
Definition
- Initial value
- 0
- 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
- Animatable
- yes
- JavaScript syntax
- object.style.maskBorderSlice
Syntax
mask-border-slice: <number-percentage>{1,4} [fill];
Values
- <number-percentage>{1,4}Specifies 1 to 4 values that define the inward offsets from the sides of the mask image. These can be numbers (pixels, etc.) or percentages of the image’s dimensions.
- 1 value: Applies to all four sides.
- 2 values: First value → top & bottom, second value → left & right.
- 3 values: Top, left & right, bottom.
- 4 values: Top, right, bottom, left.
- [fill]Indicates whether the middle section of the mask should be scaled and used to fill the content box. If
fillis specified, the center portion of the sliced mask is applied inside the element; otherwise, only the borders use the mask.
Example
Browser Support
The following information will show you the current browser support for the CSS mask-border-slice 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
Tablets & Mobile
Last updated by CSSPortal on: 1st January 2026
