Skip to the page
css reference · the box model

CSS box-shadow

type
property
applies to
any element
inherits
no
common values
x y blur spread colour, e.g. 0 4px 12px rgba(0,0,0,.15); none

Where it goes

On cards, dropdowns, popups, buttons, and anything that should look raised. It does not change layout. The shadow is painted outside the box without pushing neighbors, and it follows border-radius.

Example

.card {
  border-radius: 12px;
  box-shadow: 0 1px 2px rgba(0,0,0,.06), 0 8px 24px rgba(0,0,0,.12);
}
.card:hover { box-shadow: 0 12px 32px rgba(0,0,0,.18); }

Common mistakes

  • Using solid black. Real shadows are see-through. A low-alpha rgba() lets the background show through and looks far less like a sticker.
  • Reaching for a huge blur to make it "pop." A big hard shadow looks like a smear. Small offset, moderate blur, low alpha reads as depth.
  • Expecting it to add space. It does not. If a shadow is cut off by a parent, the parent has overflow: hidden, not a missing margin.

Related

Updated 24 October 2026. Practice it in the css route, or read more on MDN.