Favorites

drop-shadow() CSS Function

drop-shadow()
CSS FunctionThis function is supported by all modern browsers.
Updated 21st November 2026

The drop-shadow() filter function adds a shadow that follows the shape of an element's content, including transparent areas, unlike box-shadow.

Looks like you're using an ad blocker, and that's fine! Ads help keep CSS Portal's generators and references free, so if the site's useful to you, visit our Support page to see other ways to help.

Description

The drop-shadow() CSS function applies a shadow effect to the rendered image of an element, similar to a real-world shadow cast by a light source. Unlike other filter functions such as blur() or brightness(), which change the pixels of the element itself, drop-shadow() only affects the visible pixels of the element and ignores transparent areas. This makes it particularly useful for images with transparency, icons, or elements with non-rectangular shapes, such as img elements or elements with clip-path applied.

The function allows you to specify the horizontal offset, vertical offset, blur radius, and color of the shadow. Positive horizontal offsets move the shadow to the right, while negative values move it to the left. Positive vertical offsets move it downward, and negative values move it upward. The blur radius controls the softness of the shadow edges, and the color determines its visual tone. If the blur radius is omitted, the shadow is sharp, and if the color is omitted, it defaults to currentcolor (the element's text color). Unlike box-shadow, drop-shadow() has no spread radius and no inset keyword.

A practical example of drop-shadow() is applying it to an icon with transparency to create a subtle lift effect:

.icon {
  filter: drop-shadow(3px 3px 5px rgba(0, 0, 0, 0.5));
}

Here, the shadow is offset 3px both horizontally and vertically, blurred by 5px, and has a semi-transparent black color. Unlike the box-shadow property, which only works with the element’s rectangular box, drop-shadow() respects the alpha transparency of the element, producing a more natural effect for irregular shapes.

Additionally, multiple shadows can be applied by separating each drop-shadow() with a space, similar to how background layers can stack. This allows complex shadow effects without additional markup.

Interactive Demo

Demo Code
HTML Code
<svg class="demo-element" viewBox="0 0 120 110" width="160" xmlns="http://www.w3.org/2000/svg"><path d="M60 5 L75 42 L115 42 L83 66 L95 105 L60 82 L25 105 L37 66 L5 42 L45 42 Z" fill="#f72585"/></svg>
CSS Code
.demo-element {
	display: block;
	margin: 15px 40px;
	filter: drop-shadow(8px 8px 0 #4361ee);
}

Syntax

drop-shadow() = drop-shadow( [ <color>? && <length>{2,3} ] )

Values

  • offset-xThe horizontal offset of the shadow. Positive values move the shadow to the right, negative values to the left. Required.
  • offset-yThe vertical offset of the shadow. Positive values move the shadow down, negative values up. Required.
  • blur-radiusOptional. The blur radius of the shadow as a <length>. The larger the value, the softer and wider the shadow. Defaults to 0, which gives a sharp shadow. Negative values are not allowed.
  • colorOptional. The color of the shadow, in any CSS color format. It can be written before or after the lengths. Defaults to currentcolor.

Example

<body>

<div class="container">
<div class="shadow-box">
<p>CSS Drop Shadow</p>
</div>
</div>

</body>
/* Container for alignment */
.container {
display: flex;
justify-content: center;
align-items: center;
height: 100vh;
background-color: #f0f0f0;
}

/* The element receiving the shadow */
.shadow-box {
padding: 2rem;
background-color: white;
border-radius: 15px;
font-family: sans-serif;
font-weight: bold;

/* The drop-shadow function */
/* Parameters: X-offset, Y-offset, Blur, Color */
filter: drop-shadow(8px 8px 10px rgba(0, 0, 0, 0.3));

/* Comparison note:
Unlike box-shadow, if this element had a
transparent background, the shadow would
appear directly under the text! */
}
Open in editor

Browser Support

The following information will show you the current browser support for the CSS drop-shadow() function. Hover over a browser icon to see the version that first introduced support for this CSS function.

This function is supported by all modern browsers.

Desktop

Chrome
Edge
Firefox
Opera
Safari

Tablets & Mobile

Chrome Android
Firefox Android
Opera Android
Safari iOS
Samsung Internet
Android WebView
-
Supported Unknown Not supported

Looks like you're using an ad blocker, and that's fine! Ads help keep CSS Portal's generators and references free, so if the site's useful to you, visit our Support page to see other ways to help.