CSS mask-border-outset Property
The CSS mask-border-outset property specifies how far a mask border extends beyond an element's border box.
It accepts one to four nonnegative length or number values, allowing each side to extend by a different amount. The property works with mask-border-source, mask-border-slice, and mask-border-width to position a mask border without changing the element's layout dimensions.
mask-border-outset Syntax
The mask-border-outset property accepts one to four nonnegative length or number values. Values follow the same top, right, bottom, and left order used by properties such as margin and padding.
Basic Syntax
selector {
mask-border-outset: <length-percentage>;
}
More precisely, the property accepts one to four nonnegative <length> or <number> values. Percentages are not permitted.
Single Length Value
.element {
mask-border-outset: 10px;
}
Two Values
.element {
mask-border-outset: 10px 20px;
}
Three Values
.element {
mask-border-outset: 10px 20px 15px;
}
Four Values
.element {
mask-border-outset: 5px 10px 15px 20px;
}
Number Value
.element {
mask-border-outset: 2;
}
No Outset
.element {
mask-border-outset: 0;
}
CSS-Wide Keywords
.element {
mask-border-outset: initial;
}
.element {
mask-border-outset: inherit;
}
.element {
mask-border-outset: unset;
}
.element {
mask-border-outset: revert;
}
.element {
mask-border-outset: revert-layer;
}
The initial value is 0, meaning the mask border area does not extend beyond the element's border box.
Property Values
| Value | Description |
|---|---|
<length> |
Specifies a fixed or relative distance beyond the corresponding side of the border box. |
<number> |
Specifies a multiplier of the corresponding computed CSS border width. |
0 |
Specifies no additional outset beyond the border box. |
initial |
Resets the property to 0. |
inherit |
Inherits the computed value from the parent element. |
unset |
Resets the property to 0 because it is not inherited. |
revert |
Reverts the property according to cascade origin rules. |
revert-layer |
Reverts the property according to cascade layer rules. |
Property Characteristics
| Characteristic | Value |
|---|---|
| Initial value | 0 |
| Inherited | No |
| Applies to | All elements, with SVG-specific applicability rules |
| Computed value | Lengths become absolute lengths; numbers remain as specified |
| Animation type | By computed value type |
| Negative values | Not permitted |
| Percentage values | Not permitted |
| Shorthand property | mask-border |
| Browser availability | Limited availability |
How It Works
The mask border area normally follows the element's border box. The mask-border-outset property expands that area outward by the specified distances.
The browser uses the expanded area when placing the sliced mask border image. This changes the geometry of the masking effect without increasing the element's dimensions in document layout.
Default Outset
.element {
mask-border-outset: 0;
}
The mask border area aligns with the border box.
Expanded Mask Border
.element {
mask-border-outset: 15px;
}
The mask border area extends 15 pixels beyond each side of the border box.
Different Distances
.element {
mask-border-outset: 5px 15px 10px 20px;
}
The mask border area extends by different amounts on the top, right, bottom, and left.
Mask Border Source Required
The property does not create a mask border by itself. A valid mask image must be supplied through mask-border-source or the mask-border shorthand.
Layout Behavior
The expanded mask border does not change the element's width, height, margin, or position in document flow. Adjacent elements are not automatically moved to make room for the outset.
Important Consideration
Masking is a rendering effect. Other clipping and painting constraints may prevent portions of an expanded mask border from being visible.
Length Values
Length values specify the distance that the mask border area extends beyond the corresponding edge of the border box.
Pixel Values
.element {
mask-border-outset: 12px;
}
The mask border area extends 12 pixels beyond all four sides.
Relative Length Values
.element {
mask-border-outset: 1em;
}
The distance is calculated using the element's font size.
Root-Relative Length Values
.element {
mask-border-outset: 1rem;
}
The distance is calculated relative to the root element's font size.
Mixed Length Values
.element {
mask-border-outset: 10px 1em 15px 2rem;
}
Different supported length units can be combined in a single declaration.
Calculated Length
.element {
mask-border-outset: calc(10px + 0.5rem);
}
The calc() function can calculate a length from compatible values.
Important Consideration
Percentages are not valid mask-border-outset values. Use a length or a unitless number instead.
Number Values
A unitless number specifies a multiplier of the corresponding computed CSS border width.
Double the Border Width
.element {
border: 10px solid transparent;
mask-border-outset: 2;
}
The mask border area extends 20 pixels beyond each side because the multiplier is 2 and the computed border width is 10 pixels.
Half the Border Width
.element {
border: 12px solid transparent;
mask-border-outset: 0.5;
}
The mask border area extends 6 pixels beyond each side.
Different Border Widths
.element {
border-style: solid;
border-color: transparent;
border-width: 5px 10px 15px 20px;
mask-border-outset: 2;
}
The resulting outsets are 10 pixels on top, 20 pixels on the right, 30 pixels on the bottom, and 40 pixels on the left.
Mixed Numbers and Lengths
.element {
border: 10px solid transparent;
mask-border-outset: 2 15px 1.5 20px;
}
Unitless numbers use border-width multipliers, while lengths specify direct distances.
Important Consideration
If the corresponding computed border width is zero, a unitless multiplier produces zero outset on that side. Use a length value when the outset must be independent of the CSS border width.
One to Four Values
The property accepts up to four values using the familiar clockwise CSS side order.
One Value
.element {
mask-border-outset: 10px;
}
All four sides extend by 10 pixels.
Two Values
.element {
mask-border-outset: 10px 20px;
}
The top and bottom extend by 10 pixels. The right and left extend by 20 pixels.
Three Values
.element {
mask-border-outset: 10px 20px 15px;
}
The top extends by 10 pixels, the right and left by 20 pixels, and the bottom by 15 pixels.
Four Values
.element {
mask-border-outset: 5px 10px 15px 20px;
}
The values apply to the top, right, bottom, and left, respectively.
Value Order Reference
| Number of Values | How Values Are Applied |
|---|---|
| One | All four sides |
| Two | Top and bottom | Right and left |
| Three | Top | Right and left | Bottom |
| Four | Top | Right | Bottom | Left |
Important Consideration
Unlike properties such as margin, negative values are not allowed. Every outset distance must be zero or greater.
Outset vs. Width
The mask-border-outset and mask-border-width properties control different aspects of mask border geometry.
| Property | Purpose |
|---|---|
mask-border-width |
Determines the widths of the regions where the sliced mask image is applied. |
mask-border-outset |
Determines how far the mask border area extends beyond the border box. |
border-width |
Determines the actual CSS border widths used in layout and as the basis for unitless multipliers. |
Mask Border Width
.element {
mask-border-width: 20px;
mask-border-outset: 0;
}
The mask border regions are 20 pixels wide, but the mask border area does not extend beyond the border box.
Mask Border Outset
.element {
mask-border-width: 20px;
mask-border-outset: 10px;
}
The mask border regions remain 20 pixels wide, while the overall mask border area extends 10 pixels beyond the border box.
Using a Border Width Multiplier
.element {
border: 8px solid transparent;
mask-border-width: 20px;
mask-border-outset: 2;
}
The mask border width is 20 pixels, while the outset is 16 pixels. The unitless outset is calculated from border-width, not mask-border-width.
Important Consideration
Increasing mask-border-outset does not automatically increase mask-border-width. The two values are independent.
Using the mask-border Shorthand
The mask-border-outset property is one of six longhand properties represented by the mask-border shorthand.
Shorthand Example
.element {
mask-border: url("border-mask.png") 30 fill / 20px / 10px round alpha;
}
The first slash introduces the mask border width. The second slash introduces the outset.
Equivalent Longhand Declarations
.element {
mask-border-source: url("border-mask.png");
mask-border-slice: 30 fill;
mask-border-width: 20px;
mask-border-outset: 10px;
mask-border-repeat: round;
mask-border-mode: alpha;
}
Shorthand with a Number Outset
.element {
border: 10px solid transparent;
mask-border: url("border-mask.png") 30 fill / 20px / 2 round;
}
The unitless outset value of 2 produces a 20-pixel extension beyond each side of the border box.
Override the Shorthand
.element {
mask-border: url("border-mask.png") 30 fill / 20px round;
mask-border-outset: 15px;
}
The later longhand declaration adds a 15-pixel outset.
Shorthand Reset Behavior
.element {
mask-border-outset: 15px;
mask-border: url("border-mask.png") 30 fill / 20px round;
}
The later shorthand resets mask-border-outset to its initial value of 0 because no outset is specified.
Interaction with mask
.element {
mask-border: url("border-mask.png") 30 fill / 20px / 10px;
mask: linear-gradient(black, transparent);
}
The later mask shorthand resets all mask border properties, including mask-border-outset.
Important Consideration
Declare mask-border after mask, and place any longhand overrides after the corresponding shorthand declarations.
mask-border-outset Example
This example illustrates how an outset expands a mask border area beyond an element's border box. Because browser support for mask-border-outset is limited, the Browser Result uses an outline to provide a reliable visual comparison of the distances.
HTML Example
<div class="mask-outset-demo">
<div class="mask-outset-item">
<div class="mask-outset-box outset-zero">0px Outset</div>
</div>
<div class="mask-outset-item">
<div class="mask-outset-box outset-ten">10px Outset</div>
</div>
<div class="mask-outset-item">
<div class="mask-outset-box outset-twenty">20px Outset</div>
</div>
</div>
CSS Example
.mask-outset-demo {
display: grid;
grid-template-columns: repeat(3, minmax(0, 1fr));
gap: 30px;
padding: 30px;
background-color: #f1f5f9;
}
.mask-outset-item {
padding: 20px;
}
.mask-outset-box {
display: flex;
align-items: center;
justify-content: center;
min-height: 100px;
padding: 10px;
background-color: #2563eb;
color: #fff;
font-weight: bold;
text-align: center;
outline: 2px dashed #475569;
}
.outset-zero {
outline-offset: 0;
}
.outset-ten {
outline-offset: 10px;
}
.outset-twenty {
outline-offset: 20px;
}
The dashed outlines represent the distances by which a mask border area would extend beyond the border box. The boxes retain their original layout dimensions.
This is a geometric illustration, not a rendered mask border. The CSS outline-offset property is used only to visualize the distances consistently across browsers.
Actual mask-border-outset Declarations
.outset-zero {
mask-border-source: url("border-mask.png");
mask-border-slice: 30 fill;
mask-border-width: 20px;
mask-border-outset: 0;
}
.outset-ten {
mask-border-source: url("border-mask.png");
mask-border-slice: 30 fill;
mask-border-width: 20px;
mask-border-outset: 10px;
}
.outset-twenty {
mask-border-source: url("border-mask.png");
mask-border-slice: 30 fill;
mask-border-width: 20px;
mask-border-outset: 20px;
}
These declarations show how the actual property would be used with a mask border source. The image URL is illustrative and must point to an existing mask image.
Use a Border Width Multiplier
.masked-box {
border: 10px solid transparent;
mask-border-source: url("border-mask.png");
mask-border-slice: 30 fill;
mask-border-width: 20px;
mask-border-outset: 2;
}
The mask border area extends 20 pixels beyond each side because the computed border width is 10 pixels.
Extend Only the Horizontal Sides
.masked-box {
mask-border-outset: 0 20px;
}
The top and bottom have no outset, while the left and right extend by 20 pixels.
Reset the Outset
.masked-box {
mask-border-outset: 0;
}
The mask border area returns to the element's border box.
Common Mistakes
Using Negative Values
.element {
mask-border-outset: -10px;
}
Negative outset values are invalid. Use zero or a positive value.
Using Percentages
.element {
mask-border-outset: 10%;
}
Percentage values are not supported. Use a length or a unitless number.
Confusing Unitless Numbers with Pixels
.element {
mask-border-outset: 2;
}
The value 2 is a multiplier of the corresponding computed border width, not a distance of 2 pixels.
Expecting the Property to Create a Mask Border
The property only changes the mask border area's extent. It does not provide the source image or slicing values needed to create a mask border.
Confusing Outset with Width
The mask-border-outset property expands the mask border area. The mask-border-width property controls the widths of the mask border regions.
Expecting Layout Space to Increase
Outset values do not increase the element's width, height, margin, or spacing in document flow.
Ignoring a Zero Border Width
A unitless outset multiplier produces zero distance when the corresponding computed CSS border width is zero.
Overwriting the Outset with a Shorthand
.element {
mask-border-outset: 15px;
mask-border: url("border-mask.png") 30 fill / 20px;
}
The later shorthand resets the outset to 0.
Assuming Universal Browser Support
The standardized mask-border-outset property has limited browser support. A fallback may be needed for production layouts.
Important Considerations
Keep the following points in mind when using mask-border-outset:
- The property controls how far the mask border area extends beyond the border box.
- Its initial value is
0. - The property is not inherited.
- It accepts one to four values.
- Values can be lengths or unitless numbers.
- Negative values are not permitted.
- Percentage values are not permitted.
- One value applies to all four sides.
- Two values apply to the vertical and horizontal sides.
- Three values apply to the top, horizontal sides, and bottom.
- Four values follow the top, right, bottom, and left order.
- Length values specify direct distances.
- Unitless numbers multiply the corresponding computed CSS border width.
- A zero computed border width produces zero outset when a unitless multiplier is used.
- The property does not create a mask border by itself.
- A valid source image is needed for a mask border effect.
- The property does not change document layout dimensions.
- It does not automatically add spacing around the element.
- The property is separate from
mask-border-width. - It is a longhand component of the
mask-bordershorthand. - The shorthand resets omitted outset values to
0. - The
maskshorthand also resets mask border properties. - Clipping and rendering constraints may affect the visible result.
- Browser support for standardized mask border properties is limited.
- Test the intended effect in the browsers your website supports.
Browser Support
The CSS mask-border-outset property has Limited availability and is not part of Baseline because it is not consistently supported across major browsers.
Some browsers implement related mask border functionality through the legacy -webkit-mask-box-image property, but this does not guarantee support for the standardized mask-border-outset longhand.
For current compatibility information, visit Can I Use? and search for mask-border-outset.
When broad compatibility is required, consider supported masking techniques or decorative alternatives that do not depend on this property.
Specifications
The mask-border-outset property is defined in CSS Masking Module Level 1.
CSS Masking Module Level 1: mask-border-outset
The specification defines the accepted values, side ordering, computed values, and relationship between mask border outsets and CSS border widths.
For additional documentation and examples, consult MDN Web Docs.
