A card with one shadow usually looks wrong in a way that is hard to name. The shadow is the right color, roughly the right size, and still the card looks pasted on rather than resting above the page. The problem is that one shadow is not what light does.

Hold a business card above a desk under a lamp and look closely. There are two shadows: a small, dark, fairly sharp one hugging the card, cast by the light that reaches it directly, and a wide, faint, soft one spread around it, cast by all the ambient light in the room. CSS lets you stack both in a single box-shadow declaration, layer by layer. This guide builds that pair with the free Box Shadow Generator on Ovatly, which assembles up to four layers and runs entirely in your browser.

Contents

  • Quick answer
  • Why one shadow looks pasted on
  • The two layers and what each one does
  • How to build the layered shadow, step by step
  • Worked example: a card shadow in two layers
  • Limitations and honest tradeoffs
  • Common mistakes
  • FAQs
  • Conclusion
  • References

Quick answer

Use two layers. The first is a wide, soft halo: horizontal offset 0px, vertical offset 8px, blur 24px, spread 0px, color #000000 at 20% opacity. The second is a tight, darker core: a small offset, a small blur and a higher opacity, with the exact values left to your eye. Build both layers in the Box Shadow Generator, then copy the combined declaration onto your card. The halo supplies the atmosphere; the core supplies the contact with the surface. Either one alone looks unfinished.

Why one shadow looks pasted on

A single shadow forces one blur value and one opacity to do two jobs at once. Make it dark and sharp enough to anchor the card, and it looks like a hard graphic offset. Make it soft and faint enough to feel like ambient light, and the card seems to float in fog, unconnected to the page.

Real shadows separate the jobs because real light arrives in two ways: directly, from a source, and indirectly, bounced off everything else in the room. The direct part is small and dark because the card blocks a nearby source cleanly. The ambient part is wide and weak because that light comes from everywhere at once. Layers are how CSS reproduces the split, and the split is what the eye has learned to expect from anything resting above a surface.

The two layers and what each one does

The halo is the ambient layer. It uses a large blur, 24px in the worked example below, so its edge dissolves completely, and a low opacity, 20%, so it tints the surface rather than covering it. Its vertical offset of 8px places the pool of shade just below the card, which reads as light coming from above. The halo is what makes the card feel raised at all.

The core is the contact layer. It sits close: a small vertical offset, a small blur, and a higher opacity than the halo. Because it is tight, it draws a definite line where the card nearly touches the page, and that line is what stops the card from looking like it hovers. The exact core values are a designer's call: how dark and how tight depends on how high the card should seem to sit and how strong the imagined light is. The pattern is fixed, though. The core is always smaller, darker and sharper than the halo.

Order matters as well. When layers are listed in one declaration, the first layer is drawn on top of the ones after it, so the core goes first and the halo spreads out beneath it. Neither layer in this recipe is inset; both are cast outside the card, where a resting object's shadow belongs.

How to build the layered shadow, step by step

  1. Open the Box Shadow Generator and set up the first layer as the halo: horizontal offset 0px, vertical offset 8px, blur 24px, spread 0px, color #000000 at 20% opacity.
  2. Add a second layer for the core: a small vertical offset, a small blur, spread 0px, and the same black at a higher opacity.
  3. Look at the preview against a background like your page's. The card should show a crisp shadow line at its base and a soft pool of shade beneath that.
  4. Adjust the core's opacity until the contact line reads clearly without turning into a hard graphic edge.
  5. Copy the combined declaration and paste it into your card's CSS as its box-shadow value.

Worked example: a card shadow in two layers

Start with the halo, exactly as the generator's example sets it:

box-shadow: 0px 8px 24px 0px rgba(0, 0, 0, 0.2);

Applied alone, a card wearing only this shadow looks gently lifted but slightly vague, as if seen through tissue. Now add a core layer. One reasonable setting, offered as a starting point rather than a rule, is an offset of 0px and 2px, a blur of 4px, spread 0px and black at 35% opacity. The combined declaration is:

box-shadow: 0px 2px 4px 0px rgba(0, 0, 0, 0.35), 0px 8px 24px 0px rgba(0, 0, 0, 0.2);

The core, listed first, is drawn over the halo. Now the card has a definite shadow line at its base and a soft pool beneath it: contact and atmosphere. If the card should feel higher, raise the halo's offset and blur and let the core follow slightly. If it should feel heavier, deepen the core's opacity. The generator allows up to four layers, so a very tall element can add a third, even wider and fainter halo, but two layers cover most cards.

Limitations and honest tradeoffs

Layers imitate light; they do not simulate it. The shadow will not bend around nearby objects, will not match a photograph's light direction unless you set the offsets to agree with it, and will not change as the element moves. Two layers also demand restraint: every extra layer is another chance to make the card look dirty, especially on light backgrounds, where stacked grey washes read as smudges. And a layered shadow belongs to a design language. A page of flat, borderless cards gains nothing from one hero card with a realistic shadow; it just looks like it wandered in from another site.

Common mistakes

  • Making the core too wide. If the core's blur is nearly as large as the halo's, the two layers merge into one vague shadow and the recipe collapses.
  • Making the halo too dark. The ambient layer should tint the surface, not cover it. If the halo is the first thing you notice, its opacity is too high.
  • Giving the core a larger offset than the halo. The contact line then detaches from the card and floats below it, which reads as a rendering error.
  • Using all four layers because they exist. Extra layers earn their place only when the element sits very high. On an ordinary card they add dirt, not depth.
  • Tuning on the wrong background. A shadow balanced on white can disappear on a tinted section or turn harsh on a dark one. Check the final values where the card will actually sit.

FAQs

Why does a single box shadow look fake? One layer forces a single blur and opacity to do two jobs: anchoring the card and suggesting ambient light. Real light splits those jobs. A direct source casts a small, dark shadow, and ambient light casts a wide, faint one, so the eye expects both.

How many layers can I stack in the generator? Up to four layers in a single box-shadow declaration. The recipe in this guide uses two. A third, wider and fainter halo can help a modal or a card that should look very high, but most cards are finished at two.

Which layer should be darker? The core. It sits closest to the card with a small offset and a small blur, so it needs a higher opacity than the halo to read as the dark line where the card nearly touches the surface.

What exact values should the core layer use? That is a designer's call, because it depends on how high the card should seem to sit and how strong the imagined light is. Keep the pattern fixed: smaller offset than the halo, smaller blur, higher opacity. An offset of 0px and 2px with 4px of blur and black at 35% is a reasonable starting point to adjust from.

Is anything uploaded when I use the generator? No. The Box Shadow Generator runs in your browser and produces a CSS declaration for you to copy. Nothing about your design or your values is sent anywhere.

Conclusion

A realistic card shadow is two shadows wearing one declaration: a tight, darker core for contact and a wide, soft halo for atmosphere. The Box Shadow Generator stacks them layer by layer, up to four, and hands you the combined CSS to copy. If you are still deciding how soft any single layer should be, our comparison of soft vs hard shadows isolates the blur setting on its own. For more guides in this series, see our Website and Webmaster Tools guides.

References