CSS Masking - mask-border Property
The mask-border CSS property helps you in creating a mask along the edge of an element's border.
The CSS property mask-border is a shorthand property to different longhand properties, which are described in the lower section.
Possible values
The CSS property mask-border can list one of the following values:
<'mask-border-source'>: Determines the source image. Refer mask-border-source for details.
<'mask-border-slice'>: Specifies the dimensions required for slicing the source image into different regions. Maximum upto four values can be specified. Refer >mask-border-slice for details.
<'mask-border-width'>: Determines the width of the border mask. Maximum upto four values can be specified. Refer mask-border-width for details.
<'mask-border-outset'>: Determines the distance between the border mask and the element's outside edge. Maximum upto four values can be specified. Refer mask-border-outset for details.
<'mask-border-repeat'>: Specifies the way the edges of the source image are adjusted in order to fit the dimensions of the border mask. Maximum upto two values can be specified. Refer mask-border-repeat for details.
<'mask-border-mode'>: Determines whether the source image is to be treated as a luminance mask or alpha mask. Maximum upto four values can be specified. Refer mask-border-mode for details.
Applies to
All HTML elements. And in case of SVG, it applies to the container element excluding the <defs> element and all graphics elements
Syntax
mask-border = <'mask-border-source'> ||
<'mask-border-slice'> [ / <'mask-border-width'>? [ / <'mask-border-outset'> ]? ]? ||
<'mask-border-repeat'> ||
<'mask-border-mode'>
CSS mask-border - Basic Example
The following example demonstrates the use of the CSS property mask-border, where an image is passed as the mask source image and other longhand property values are passed:
<html>
<head>
<style>
.with-mask {
-webkit-mask-box-image: url("images/logo.png")
20 fill / /* slice */
10px / /* width */
2px /* outset */
round; /* repeat */
mask-border: url("images/logo.png")
20 fill / /* slice */
10px / /* width */
2px /* outset */
round; /* repeat */
}
</style>
</head>
<body>
<h1>The mask-border Property</h1>
<h3>With mask-border</h3>
<div class="with-mask">
<img src="images/border.png" alt="mask border image" width="300" height="200">
</div>
<h3>Without mask-border</h3>
<img src="images/border.png" alt="mask border image" width="300" height="200">
</body>
</html>
CSS mask-border - Related Properties
The table given below lists the various longhand properties that are passed to the mask-border property:
| Property | Description |
|---|---|
| mask-border-mode | Determines whether the source image is to be treated as a luminance mask or alpha mask. |
| mask-border-outset | Determines the distance between the border mask and the element's outside edge. |
| mask-border-repeat | Specifies the way the edges of the source image are adjusted in order to fit the dimensions of the border mask. |
| mask-border-slice | Specifies the dimensions required for slicing the source image into different regions. |
| mask-border-source | Determines the source image. |
| mask-border-width | Determines the width of the border mask. |