box-shadow vs drop-shadow: When to Use Each
October 2, 2026 | 8 min read | CSS
By Syed · Frontend Engineer & Creator of UITweak
Both make shadows, but they work in completely different ways, and picking the wrong one is why shadows sometimes look broken. box-shadow draws a shadow of the element's box. The drop-shadow() filter draws a shadow of the element's rendered shape, following transparency. Once you see the difference, the choice becomes obvious every time.
Shortcut: design both kinds of shadows visually in our free Shadow Studio, then fine-tune them with the recipes below. For realistic multi-layer shadows, see our layered box shadows guide.
1. The Core Difference in One Picture
Imagine a PNG logo with a transparent background, or an SVG icon. Apply box-shadow and you get a rectangle: the shadow follows the element's box, ignoring the transparent parts. Apply filter: drop-shadow() and the shadow hugs the actual visible shape, tracing every curve of the logo and skipping the transparency.
/* Shadow of the BOX: rectangle, ignores transparency */
.logo {
box-shadow: 0 12px 24px rgb(0 0 0 / 0.25);
}
/* Shadow of the SHAPE: follows transparency */
.logo {
filter: drop-shadow(0 12px 16px rgb(0 0 0 / 0.25));
}That is the entire mental model. box-shadow knows about boxes. drop-shadow() knows about pixels.
2. When to Use box-shadow
Reach for box-shadow whenever the element is a solid rectangle, which covers most UI:
- Cards, buttons, inputs, modals. The box is the shape, so the shadow is correct by default.
- Layered realistic shadows.
box-shadowaccepts a comma-separated list, so you can stack a tight ambient shadow under a soft distant one. Our layered technique builds exactly this. - Inset shadows. Only
box-shadowsupportsinsetfor pressed or engraved effects.drop-shadow()has no inset. - Spread control. The spread radius lets you grow or shrink the shadow, which
drop-shadow()cannot do.
.card {
/* layered: tight key light + soft ambient */
box-shadow:
0 1px 2px rgb(0 0 0 / 0.08),
0 8px 24px rgb(0 0 0 / 0.12);
}
.btn-pressed {
/* only box-shadow can do inset */
box-shadow: inset 0 2px 6px rgb(0 0 0 / 0.2);
}3. When to Use drop-shadow
Reach for filter: drop-shadow() whenever the visible shape is not a rectangle:
- Transparent PNGs and logos. The shadow follows the artwork, not the image box.
- SVG icons. A bell or star icon gets a shadow shaped like the icon itself.
- Text effects.
drop-shadow()on text follows the glyphs, giving a glow thattext-shadowapproximates but with full filter syntax. - Clip-path and masked elements. The shadow respects the clipped shape.
/* Icon shadow that follows the icon's shape */
.icon {
filter: drop-shadow(0 4px 8px rgb(0 0 0 / 0.3));
}
/* Soft glow on a headline */
.hero-title {
filter: drop-shadow(0 0 24px rgb(99 102 241 / 0.55));
}4. Can You Combine Them?
Yes, and it is a legitimate technique. Use box-shadow for the card's own depth and drop-shadow() for a child element with transparency, like a floating product image inside the card. Just remember they are separate properties, so they compose without conflict:
.product-card {
/* card depth from the box */
box-shadow: 0 8px 24px rgb(0 0 0 / 0.12);
}
.product-card img {
/* image shadow follows the product cutout */
filter: drop-shadow(0 16px 16px rgb(0 0 0 / 0.25));
}5. Performance: box-shadow Usually Wins
drop-shadow() is a filter, and filters force the browser to do extra compositing work on every frame while the element animates. For static elements the difference is negligible, but for animated ones it matters:
- Animating an element with
drop-shadow()is noticeably more expensive than animating one withbox-shadow. - Large blurred
box-shadowvalues are also costly, but they are still cheaper than the equivalent filter. - Rule of thumb: default to
box-shadowfor anything that moves, and reservedrop-shadow()for static shaped elements.
6. One-Sided Shadow Trick
A common follow-up question: how do you get a shadow on only one side? With box-shadow, use a negative spread to pull the shadow tight, then offset it in one direction:
/* shadow only below the element */
.one-sided {
box-shadow: 0 16px 16px -8px rgb(0 0 0 / 0.25);
}The negative spread shrinks the shadow so it barely peeks out, and the vertical offset pushes the visible part downward. Adjust the numbers to show the shadow on any single side.
The clipping rules, side by side
Neither shadow affects layout. Both paint outside the element's box without moving anything else. The difference is what can cut them off. box-shadow is painted by the element, so any ancestor with overflow: hidden, overflow: auto, or overflow: scroll clips it. This is the classic "my dropdown shadow is cut off inside the card" bug. drop-shadow() behaves the same way, because the filter output is still the element's own painting. The practical takeaway: when a shadow is clipped, the fix is never on the shadow. It is on the ancestor. Either remove the overflow, move the element out of the clipped subtree, or accept the crop. One more subtlety: border-radius never clips an outer shadow. If your shadow looks cut along a curve, the culprit is an ancestor's overflow, not the radius.
filter: drop-shadow() changes your containing block
This is the trade-off that surprises people. Applying any filter, including drop-shadow(), makes the element a containing block for absolutely positioned descendants. box-shadow does not. Concretely: a tooltip is absolutely positioned inside a card, anchoring to a relatively positioned wrapper further up the tree because the card itself is static. You swap the card's box-shadow for filter: drop-shadow() to get a nicer shaped shadow. The card silently becomes the containing block, and the tooltip jumps to a new position. I have seen this break floating labels the moment someone "upgrades" a shadow to a filter. The rule: never put drop-shadow() on a container that holds absolutely positioned children unless you have checked where they anchor. If you need the shaped shadow and the old positioning, wrap the elements: an outer div carries the positioning context, an inner div carries the filter.
The stacking-context side effect
One more filter consequence worth knowing before you swap shadows on a whim. Any filter, including drop-shadow(), forces the element into its own stacking context. box-shadow does not. In practice this means a drop-shadow() element can no longer interleave its z-index with siblings outside that context: children with z-index: 999 inside the filtered element will never paint above a sibling of the element itself that has z-index: 1. If you have ever added a filter to a card and watched its dropdown menu slide underneath a neighboring card, this is why. The fix is the same wrap pattern as above. Keep filters on leaf elements that do not need to participate in page-level z-index fights, and keep stacking contexts on plain containers.
Debugging: why your shadow is invisible
Run this checklist before touching the values. One, an ancestor with overflow: hidden is clipping it. Temporarily set overflow: visible on parents until the shadow appears, then decide which ancestor actually needs the clipping. Two, the shadow color matches the background. A dark shadow on a dark surface is invisible, not missing. Three, you wrote drop-shadow() on an element with no transparency. On a solid rectangle it looks identical to box-shadow, which is correct behavior, not a bug. Four, display: contents on the element. That removes the box entirely, and box-shadow has no box to draw from. Five, a sibling with a higher stacking order is painting over the part of the shadow that extends past the element's edge. Six, you typed inset when you meant an outer shadow, or the spread is so negative the shadow collapsed to nothing. In my experience, eight times out of ten it is the overflow ancestor. Check that first.
Frequently Asked Questions
Which is better, box-shadow or drop-shadow?
Neither is better in general. Use box-shadow for boxes, cards, and anything needing inset or spread. Use drop-shadow() for transparent images, icons, and text where the shadow must follow the visible shape.
Why does my drop-shadow look like a rectangle?
You are probably looking at box-shadow, not drop-shadow(). Double-check you wrote filter: drop-shadow(...). If the element has no transparency, both look identical, which is also fine.
Does drop-shadow work on text?
Yes. Applied to a text element, the shadow follows the glyph shapes. For simple text shadows text-shadow is lighter, but drop-shadow() gives you blur and color in full filter syntax.
Is drop-shadow slower than box-shadow?
Generally yes, because filters add compositing cost, especially during animation. For static elements you will not notice. For animated elements, prefer box-shadow.
Try it now: build both shadow types visually in the free Shadow Studio, then level up to realistic depth with our layered box shadows guide.