A single box-shadow almost always looks slightly wrong. It is either a hard dark smear that makes a card look pasted on, or a soft grey cloud that makes it look like it is hovering over the page. The problem is not your values. The problem is that one shadow is being asked to do two jobs at once.
Look at the shadow under a real object on a desk. There is a dark, fairly sharp band right where the object meets the surface, and around it a much wider, fainter spread where the ambient light is blocked. CSS lets you stack several shadows on one element to reproduce exactly that structure, and this guide shows how to build them with the free Box Shadow Generator on Ovatly.
Contents
- Quick answer
- Why one shadow rarely looks real
- What each layer is for
- Layer order: the first one paints on top
- How to build multiple shadows, step by step
- Worked example: a two-layer card shadow
- Limitations and honest tradeoffs
- Common mistakes
- FAQs
- Conclusion
- References
Quick answer
Give each layer one job. Layer one is the wide soft halo: a larger vertical offset, a large blur and a low opacity. Layer two is the tight dark core: a small offset, a small blur and a higher opacity. In the Box Shadow Generator, build the halo first, add a second layer for the core, check the combined preview, then copy the single comma-separated declaration into your stylesheet. Two layers cover most elements; add a third only for a specific effect such as a colored glow or an inset edge.
Why one shadow rarely looks real
A CSS shadow is a blurred copy of the element's box, offset from the element and tinted with a color. One layer gives you one blur radius and one opacity. Real light does not work that way. The part of the shadow close to the object is sharp because little light leaks in from the sides. Further out, light arrives from many angles, so the shadow fades and softens.
That is why a single shadow forces a bad compromise. Set the blur low and the shadow looks like a dark duplicate of the box. Set it high and the contact area washes out, so the element loses its anchor to the surface. Splitting the work across two layers removes the compromise: each layer keeps the blur and opacity that suit its job.
What each layer is for
Think of the layers as separate light effects that happen to share one declaration.
The core is the contact shadow. Small vertical offset, small blur, and the darkest color of the set. It tells the eye exactly where the element touches the surface beneath it. Without a core, elements drift.
The halo is the ambient shadow. Bigger offset, generous blur, low opacity. It tells the eye how high the element sits and how soft the light is. Without a halo, elements look stamped on.
A colored glow is an optional third layer: a shadow in a brand color instead of black or grey, usually with small offsets and a large blur. It reads as light spilling from the element rather than shadow falling from it, so use it deliberately.
An inset edge is the other optional layer. Toggling inset on a layer draws that shadow inside the border instead of outside it, which gives a pressed, recessed or inner-glow effect. Inset layers combine freely with outer ones, so a button can sit raised on the page while its top edge looks carved in.
Layer order: the first one paints on top
When several shadows are listed in one declaration, CSS paints them in order: the first shadow is drawn on top, and each later one goes behind the ones before it. This matters most where the core and halo overlap, directly under the element. If the wide pale halo were painted over the core, it would wash the core out.
So write the declaration with the tightest, darkest layer first and the softest, palest layer last. The generator keeps the layers in the order you build them, which makes the safe habit simple: core first, halo second, any extras after that.
How to build multiple shadows, step by step
- Open the Box Shadow Generator. Start with layer one, the halo: set a vertical offset, a large blur radius, no spread, and a low opacity on the color.
- Add a second layer for the core: smaller offset, much smaller blur, and a noticeably higher opacity.
- Read the preview, not the numbers. The element should look seated: a clear dark line of contact, then a gentle fade outward.
- If you need an effect layer, add it now: a colored glow, or an inset layer with the inset toggle on. Stop at four layers, and ask what each one does before keeping it.
- Copy the finished declaration and paste it into your stylesheet as the element's
box-shadowvalue.
Worked example: a two-layer card shadow
Start with a single soft layer, the kind many designs ship by default: offsets 0px and 8px, blur 24px, spread 0px, color #000000 at 20% opacity. The generator produces:
box-shadow: 0px 8px 24px 0px rgba(0, 0, 0, 0.2);
On its own this reads as a gentle float. The card is clearly lifted, but nothing pins it down. Now add the missing core as a second layer: offsets 0px and 2px, blur 6px, spread 0px, and the same black at 35% opacity. Built in that order, core first, the combined declaration is:
box-shadow: 0px 2px 6px 0px rgba(0, 0, 0, 0.35), 0px 8px 24px 0px rgba(0, 0, 0, 0.2);
Nothing about the halo changed. What changed is that the card now has a contact point: a short, darker shadow hugging its bottom edge, with the soft spread falling behind it. That one extra layer is the difference between a card that hovers and a card that rests. Most real interfaces stop here.
Limitations and honest tradeoffs
The generator builds up to four layers, and that ceiling is a genuine constraint for elaborate effects. Layered shadows beyond four, such as long retro shadows built from dozens of stepped copies, are outside what it produces.
Every layer is a full copy of the element's box shape. Box shadows follow the element's rectangle (with its border radius), not the outline of an irregular image. For drop shadows that trace a transparent PNG's actual shape, CSS filters are the right tool, not box-shadow.
Finally, stacked shadows cost rendering work. Two layers on a card are nothing; four heavy-blur layers on hundreds of list items can make scrolling feel sluggish on weak hardware. Spend layers where the eye actually lands.
Common mistakes
- Making every layer the same shape with different opacity. That just rebuilds one shadow at higher cost. Each layer needs its own offset and blur.
- Putting the halo first. The pale layer paints over the core and the contact shadow disappears. Core first, always.
- Reaching for four layers because four exist. If you cannot name the job a layer does, delete it. Two good layers beat four vague ones.
- Using pure black at high opacity for the halo. Ambient shadow is weak light, not darkness. Keep halo opacity low or it reads as dirt.
- Copying a shadow from a dark design onto a light one unchanged. Shadow visibility depends on the background. Rebuild against your own surface color and check the preview there.
FAQs
How many shadows can one element have? The Box Shadow Generator builds up to four layers in a single declaration, and all of them render together. Four is a ceiling, not a target: most cards, buttons and panels look right with two.
Which layer should come first in the declaration? Put the tight core first. CSS paints the first shadow in the list on top of the others, so the darker, sharper layer belongs at the front where it stays visible against the softer halo behind it.
What is the difference between the core and the halo? The core is the dark contact shadow directly beneath the element: small offset, small blur, higher opacity. The halo is the ambient spread: larger offset and blur, lower opacity. Real objects cast both at once.
Can I combine an inset shadow with outer shadows? Yes. Each layer has its own inset toggle, so one layer can draw inside the border, for a pressed or recessed edge, while the other layers fall outside the element as normal.
Does the generator upload my design anywhere? No. It runs entirely in your browser and produces a line of CSS for you to copy. Nothing about your page or your values leaves your device.
Conclusion
Multiple shadows work because each layer does one honest job: the core anchors, the halo lifts, and anything beyond that is a deliberate effect. Build them in the Box Shadow Generator, keep the order core first, and stop at two layers unless a third earns its place. For the companion guide on animating between two shadow states, see Shadow on Hover: How to Animate a Subtle Lift. For more guides in this series, see our Website and Webmaster Tools guides.
References
- MDN Web Docs, on the box-shadow property, its layer order and the inset keyword: https://developer.mozilla.org/en-US/docs/Web/CSS/box-shadow
- CSS Tricks, on stacking multiple shadows and common shadow patterns: https://css-tricks.com/almanac/properties/b/box-shadow/