Open In App

CSS mask-origin property

Last Updated : 14 Jun, 2024
Comments
Improve
Suggest changes
Like Article
Like
Report

The CSS mask-origin property determines the positioning reference of a CSS mask image applied to an element using mask-image. It defines where the mask image originates within the element’s box model, influencing how the mask is positioned and clipped.

Syntax:

mask-origin: Keyword values
/* Or */
mask-origin: Multiple values
/* Or */
mask-origin: Non-standard keyword values
/* Or */
mask-origin: Global values

Property values: This property accepts the values mentioned above and described below:

CategoryDescription
Keyword valuesValues like content-box, padding-box, margin-box, border-box, fill-box, stroke-box, view-box, etc.
Non-standard keyword valuesValues like padding, border, content, etc.
Multiple valuesCombinations like padding-box, fill-box, view-box, border-box, etc.
Global valuesValues like inherit, unset, initial, etc.

Example 1: Below is the example that illustrates the mask-origin property using border-box :

html
<!DOCTYPE html>
<html>

<head>
    <style>
        .geeks {
            width: 22%;
            height: 200px;
            background: green;
            border: 10px solid red;
            padding: 10px;
            color: white;
            -webkit-mask-image:
                url("image.svg");
            -webkit-mask-repeat: repeat;
            mask-origin: border-box;
        }
    </style>
</head>

<body>

    <div class="geeks"></div>

</body>

</html>

Output:

Example 2: Below is the example that illustrates the mask-origin property using content-box :

html
<!DOCTYPE html>
<html>

<head>
    <style>
        .geeks {
            width: 22%;
            height: 200px;
            background: green;
            border: 10px solid red;
            padding: 10px;
            color: white;
            -webkit-mask-image:
                url("image.svg");
            -webkit-mask-repeat: repeat;
            mask-origin: content-box;
        }
    </style>
</head>

<body>

    <div class="geeks"></div>

</body>

</html>

Output:

Browsers Supported:



Next Article

Similar Reads