drop-shadow vs box-shadow

box-shadow paints a shadow shaped like the element's (rounded) box. filter: drop-shadow() traces the actual visible pixels — the alpha silhouette — instead.

Also known as: filter: drop-shadow()Silhouette shadow
···
html
<div class="pair">
  <div class="item"><div class="frame bs"><svg class="star" viewBox="0 0 100 100"><polygon points="50,0 61,35 98,35 68,57 79,91 50,70 21,91 32,57 2,35 39,35" fill="#5b5bf7"/></svg></div><span class="cap">box-shadow</span></div>
  <div class="item"><div class="frame"><svg class="star ds" viewBox="0 0 100 100"><polygon points="50,0 61,35 98,35 68,57 79,91 50,70 21,91 32,57 2,35 39,35" fill="#18c29c"/></svg></div><span class="cap">filter: drop-shadow()</span></div>
</div>
css
.pair{display:flex;gap:14%;align-items:flex-start}
.item{display:flex;flex-direction:column;align-items:center;gap:10px}
.frame{width:26vmin;max-width:110px;aspect-ratio:1;display:grid;place-items:center}
.frame.bs{box-shadow:0 16px 26px rgba(0,0,0,.55)}
.star{width:100%;height:100%;animation:spin 9s linear infinite;transform-origin:50% 50%}
.star.ds{filter:drop-shadow(0 16px 16px rgba(0,0,0,.55))}
.cap{font:600 12px/1.3 monospace;color:var(--muted);text-align:center}
@keyframes spin{to{transform:rotate(360deg)}}

box-shadow paints relative to the border-box. Even for a shape with transparent gaps — a star, a donut — the box is still just a rectangle (or a rounded one), so the shadow comes out rectangular too.

filter: drop-shadow() instead reads the element's alpha channel and shapes the shadow to whatever pixels are actually opaque. It follows concave notches and holes exactly, and because it's a filter, it inherits any rotate/scale the element has — the shadow turns and resizes right along with it.

Compare the two stars in the demo: the box-shadow one leaks a rectangular shadow through the star's concave notches, while the drop-shadow one hugs the star outline precisely. The trade-off is cost — drop-shadow recomputes from the alpha mask, so it's heavier than box-shadow, and it has no inset or spread option. For a plain rectangular card, where the silhouette already is the box, box-shadow is cheaper and just as good.

When to use

Use drop-shadow for icons, logos, or anything whose silhouette differs from its box. Use box-shadow for cards/buttons where the silhouette already matches the box.