liveBook · Manning

Box-shadow

As explained in Tiny CSS Projects

The CSS box-shadow property adds one or more shadows around or within an element's box.

The CSS box-shadow property adds a shadow to an element’s box, creating visual depth or separation. Its values control horizontal and vertical offset, blur, spread, and color; adding inset turns the shadow inward. section 8.2.6 section 9.7

Floating checkout cards

Give a section a white surface, rounded corners, and a soft shadow against a pale teal page background: section { background: #ffffff; border-radius: 4px; box-shadow: 2px 2px 7px #aeb7b7; }. This makes the section read as a card hovering above the page. section 8.2.6

Use box-shadow when you need to:

  • Separate containers visually without adding a heavy outline. section 8.2.6
  • Reinforce a three-dimensional floating-card effect with a large, soft, transparent shadow: box-shadow: 0 20px 60px 0 rgb(14 42 90 / 0.55);. section 9.7.1
  • Create an inward shadow by including the optional inset value. section 8.2.6

Unlike filter: drop-shadow(), box-shadow follows the element’s outer bounding box. A drop shadow can follow an image’s alpha mask, so transparent areas in PNG or SVG artwork affect its shape; use box-shadow when the rectangular container is the intended target. section 9.7.1

How Tiny CSS Projects covers it

How deep it goes
Explains offsets, blur, spread, color, inset, and bounding-box behavior, but does not detail the full grammar.
Examples
Demonstrates checkout cards, a profile card, and a virtual credit card with increasingly soft shadows.
What you can do after
Apply it via CSS to style containers and cards with controlled depth, separation, or inset shading.
How it connects
Connects box-shadow with drop-shadow, filter, border-radius, text-shadow, and image alpha masks.

Also explained in

Compare how 3 books explain box-shadow →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Tiny CSS Projects. The section links point to the parts of the book it draws on.