CSS Box Shadow Examples

Example 1: This example illustrates the use of the box-shadow property where properties such as h-offset, v-offset & blur are applied along with their values.

HTML
<!DOCTYPE html>
<html>

<head>
    <title>CSS box-shadow Property</title>
    <style>
        .gfg1 {
            border: 1px solid;
            padding: 10px;

            /* box-shadow: h-offset v-offset blur */
            box-shadow: 5px 10px 10px;
        }

        .gfg2 {
            border: 1px solid;
            padding: 10px;

            /* box-shadow: h-offset v-offset blur */
            box-shadow: 5px 10px 28px;
        }
    </style>
</head>

<body>
    <div class="gfg1">
        <h1>Welcome to w3wiki!</h1>
    </div>
    <br><br>
    <div class="gfg2"> A computer Science portal </div>
</body>

</html>

Output:

Example 2: This example illustrates the use of the box-shadow property where the spread property is applied to set the size of the shadow.

HTML
<!DOCTYPE html>
<html>

<head>
    <title>CSS box-shadow Property</title>
    <style>
        .gfg1 {
            border: 1px solid;
            padding: 10px;

            /* box-shadow: h-offset
                       v-offset blur spread */
            box-shadow: 5px 10px 10px 10px;
        }

        .gfg2 {
            border: 1px solid;
            padding: 10px;

            /* box-shadow: h-offset
                       v-offset blur spread */
            box-shadow: 5px 10px 28px 20px;
        }
    </style>
</head>

<body>
    <div class="gfg1">
        <h1>Welcome to w3wiki!</h1>
    </div>
    <br><br>
    <div class="gfg2"> A computer Science portal </div>
</body>

</html>

Output:

Example 3: This example illustrates the use of the box-shadow property where different color shade is applied.

HTML
<!DOCTYPE html>
<html>

<head>
    <title>CSS box-shadow Property</title>
    <style>
        .gfg1 {
            border: 1px solid;
            padding: 10px;

            /* box-shadow: h-offset v-offset blur 
                spread color */
            box-shadow: 5px 10px 10px 10px green;
        }

        .gfg2 {
            border: 1px solid;
            padding: 10px;

            /* box-shadow: h-offset v-offset blur 
                spread color */
            box-shadow: 5px 10px 28px 20px green;
        }
    </style>
</head>

<body>
    <div class="gfg1">
        <h1>Welcome to w3wiki!</h1>
    </div>
    <br><br>
    <div class="gfg2"> A computer Science portal </div>
</body>

</html>

Output:

Example 4: This example illustrates the use of the box-shadow property where inset property is applied to make the shadow inside the box.

HTML
<!DOCTYPE html>
<html>

<head>
    <title>CSS box-shadow Property</title>
    <style>
        .gfg1 {
            border: 1px solid;
            padding: 10px;
            /* box-shadow: h-offset v-offset blur 
                spread color inset */
            box-shadow: 5px 10px 10px 10px green inset;
        }

        .gfg2 {
            border: 1px solid;
            padding: 10px;

            /* box-shadow: h-offset v-offset blur 
                spread color inset */
            box-shadow: 5px 10px 28px 20px green inset;
        }
    </style>
</head>

<body>
    <div class="gfg1">
        <h1>Welcome to w3wiki!</h1>
    </div>
    <br><br>
    <div class="gfg2"> A computer Science portal </div>
</body>

</html>

Output:

Example 5: This example illustrates the use of the box-shadow property where the initial property is applied to set its values to the default value.

HTML
<!DOCTYPE html>
<html>

<head>
    <title>CSS box-shadow Property</title>
    <style>
        .gfg1 {
            border: 1px solid;
            padding: 10px;

            /* box-shadow: initial */
            box-shadow: initial;
        }

        .gfg2 {
            border: 1px solid;
            padding: 10px;

            /* box-shadow: initial */
            box-shadow: initial;
        }
    </style>
</head>

<body>
    <div class="gfg1">
        <h1>Welcome to w3wiki!</h1>
    </div>
    <br><br>
    <div class="gfg2"> A computer Science portal </div>
</body>

</html>

Output:

CSS box-shadow Property

CSS box shadow property is used to give a shadow-like effect to the frames of an element. The multiple effects can be applied to the element’s frame which is separated by the comma. The box-shadow can be described using X and Y offsets relative to the element, blur and spread radius, and color. The default value is none

Similar Reads

Try It:

.item { border: 1px solid gray; font-family: "Gill Sans", "Gill Sans MT", Calibri, "Trebuchet MS", sans-serif; border-radius: 3px; margin: auto; margin-top: 5px; max-width: 320px; min-width: 180px; width: 80%; cursor: pointer; background-color: rgb(133,173,179); color: rgb(255, 255, 255); font-weight: 600; letter-spacing: 1.5px; padding: 5px; font-size: 13px; } .item:hover { box-shadow: 0 0 2px grey; } @media screen and (max-width: 450px) { .container { flex-direction: column; } .snippets { border-right: none !important; border-bottom: 2px solid black; width: 100% !important; padding-bottom: 10px; } }...

CSS Box Shadow Examples

Example 1: This example illustrates the use of the box-shadow property where properties such as h-offset, v-offset & blur are applied along with their values....

Supported Browsers

The browser supported by the box-shadow property are listed below:...