Add a blur effect to the shadow with CSS

The CSS box-shadow property allows you to add shadow effects around an element. When you specify a blur radius value, it creates a soft, blurred shadow instead of a sharp one.

Syntax

selector {
    box-shadow: offset-x offset-y blur-radius color;
}

Parameters

Parameter Description
offset-x Horizontal shadow offset (required)
offset-y Vertical shadow offset (required)
blur-radius Amount of blur applied to shadow (optional)
color Shadow color (optional)

Example

The following example demonstrates how to add a blur effect to a shadow −

<!DOCTYPE html>
<html>
<head>
<style>
    h2 {
        box-shadow: 10px 10px 7px green;
        height: 50px;
        background-color: yellow;
        margin: 20px;
        display: flex;
        align-items: center;
        padding-left: 15px;
    }
</style>
</head>
<body>
    <h2>Heading Two</h2>
    <p>Above heading has a blurred green shadow.</p>
</body>
</html>
A yellow heading box appears with a green blurred shadow offset 10px right and 10px down, with a 7px blur radius creating a soft shadow effect.

Conclusion

The box-shadow property with a blur radius creates smooth, professional shadow effects. The larger the blur radius value, the softer and more diffused the shadow appears.

Updated on: 2026-03-15T12:33:25+05:30

1K+ Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements