Most CSS shadows fail in one of two ways. Either the shadow is a single dark slab that makes a card look like it is hovering over a hole, or it is so wide and faint that the element looks smudged rather than lifted. Real shadows cast by real light look like neither. An object resting near a surface throws a tight, darker shadow right where it meets that surface, and a wider, softer wash of shade around it.

A natural box-shadow copies that two-part structure with two layers instead of one. This guide explains what each box-shadow value controls, why a single layer so often looks wrong, and how to build one with the free Box Shadow Generator on Ovatly, which previews every layer on a card and hands you one declaration to copy.

Contents

  • Quick answer
  • The four numbers and a color
  • Why one layer looks fake
  • Inset shadows are a different tool
  • How to build a natural shadow, step by step
  • Worked example: a soft card shadow, then a core
  • Limitations and honest tradeoffs
  • Common mistakes
  • FAQs
  • Conclusion
  • References

Quick answer

For a natural result, stack two layers: a small, darker layer for the contact shadow and a larger, lighter layer for the soft halo. In the Box Shadow Generator, set the first layer's offsets, blur, spread, color and opacity, then add a second layer with larger offsets and blur but lower opacity. Check the live preview on the card, and copy the single box-shadow declaration the generator produces. One layer suits only the subtlest effects; two layers make a shadow read as light and depth instead of a grey outline.

The four numbers and a color

Every box-shadow layer is built from the same parts. The horizontal and vertical offsets position the shadow relative to the element: a vertical offset of 8px drops it 8 pixels below the box, as if the light were above. The blur radius softens the shadow's edge, and it cannot be negative in CSS, which is why the generator's blur slider starts at 0. The spread changes the size of the shadow shape before the blur is applied: positive spread grows it, negative spread shrinks and tightens it.

The last part is the color and its opacity. The generator emits the pair as an rgba() value, keeping the exact alpha you set, shown to two decimals where needed. That matters: a shadow at 20 percent opacity lets the page color show through, so the same declaration looks right on a white page and a tinted one, while a solid shadow color often lands too heavy on a real background.

Why one layer looks fake

A single layer has to average two different jobs. The contact shadow, the dark line where an object nearly touches the surface, needs small offsets, a small blur and stronger opacity. The halo, the ambient shade around it, needs a large blur and weak opacity. Pick one set of values and you get a compromise: blur enough for the halo and the contact edge dissolves; keep it tight for the contact edge and the halo never forms.

Stacking layers separates the jobs. One small, darker layer sits close under the element and grounds it. One large, lighter layer spreads the soft shade. The generator stacks up to four layers, but two layers carry most everyday elements: cards, buttons, menus and modals.

Inset shadows are a different tool

Ticking Inset on a layer draws that shadow inside the element's border instead of outside it. That is not a subtler version of a lifting shadow; it reverses the effect. Inset shadows make a surface look pressed in or hollowed out, right for input fields, wells and pressed buttons, and wrong for a card meant to float above the page. If a design mixes both, build the outer shadow first and add the inset deliberately, not by accident.

How to build a natural shadow, step by step

  1. Open the Box Shadow Generator and start with the first layer. Set a small vertical offset, a modest blur and no spread, then pick black as the color and an opacity around a quarter to a third. This is your contact layer.
  2. Add a second layer with a larger vertical offset, a much larger blur, and an opacity well below the first layer's. This is the halo.
  3. Check the preview card: it should look resting on the page, not glued to it and not floating over a dark patch.
  4. Adjust spread if the halo leaks too far sideways: a small negative spread pulls the shadow shape in before it blurs.
  5. Copy the generated declaration and paste it into your stylesheet. It matches the preview exactly, so what you saw is what ships.

Worked example: a soft card shadow, then a core

Start with the generator's own soft card shadow: one layer with horizontal offset 0px, vertical offset 8px, blur 24px, spread 0px, and the color #000000 at 20 percent opacity. The output is a single line:

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

On its own that is a decent halo: soft, wide, and light enough for most backgrounds. What it lacks is the contact shadow, so the card can still feel like it floats. Add a second, tighter layer in front of it (offset 0px and 2px, blur 6px, spread 0px, black at 30 percent opacity) and the combined declaration reads:

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

Read the two layers as the two parts of a real shadow. The first, darker and barely blurred, is the shade right under the card's edge. The second, wider and lighter, is the ambient wash around it.

Limitations and honest tradeoffs

The generator stacks up to four layers, which is a sensible ceiling: past that, extra layers change the result very little and make the declaration hard to maintain. Blur cannot go below zero, so the sharpest edge comes from a small offset and zero blur. Very large blur values on very large elements can be expensive for browsers to repaint; the generator allows them because print-style effects sometimes need them, but a full-screen hero with a giant blurred shadow is a real performance cost.

The tool outputs one declaration and nothing else. It will not choose which elements deserve shadows, and it cannot match the lighting of a photograph behind the element. Those calls stay with you.

Common mistakes

  • One layer at high opacity. A single dark blur reads as a slab or a hole. Split the core and the halo into two layers and lower both opacities.
  • Huge blur, tiny offset. The shadow spreads evenly on all sides and the element looks dirty rather than lifted, when it should fall mostly downward.
  • Ignoring spread. When a soft shadow leaks past the sides of a narrow element, a small negative spread tightens it better than reducing blur.
  • Inset left on by accident. An inner shadow on a raised card flattens it. Check the inset toggle when a result looks pressed instead of lifted.
  • Giant blurs on giant elements. A very large blur over a very large area costs repaint time on scroll and animation. Keep hero shadows modest.

FAQs

Why does my box-shadow look fake? Usually because one layer is doing two jobs at once. A real shadow has a tight dark core and a wide soft halo. One medium blur at one opacity averages the two and reads as a grey smudge. Stack a small darker layer and a large lighter one instead.

How many shadow layers should I use? Two covers most cards, buttons and panels: one for the contact shadow, one for the halo. The generator stacks up to four layers for a deeper lift, but more than that rarely adds realism.

What does spread do in a box-shadow? Spread grows or shrinks the shadow shape before the blur is applied. Positive spread makes the shadow larger than the element. Negative spread makes it smaller and tighter, useful for keeping a soft shadow from leaking out on every side.

What is an inset shadow? An inset shadow is drawn inside the element's border instead of outside it. It suits pressed buttons, inputs and wells, anywhere the surface should look pushed in rather than lifted. It is a different effect from an outer shadow, not a variation of one.

Does the copied CSS match what the preview shows? Yes. The generator previews each layer live on a card, and the declaration you copy is a single box-shadow value built from exactly those layers, so the pasted CSS renders the way the preview did.

Conclusion

A natural shadow is a small piece of stagecraft: a tight dark core to ground the element, a wide soft halo to suggest the light, and opacities low enough to let the page show through. Build both layers in the Box Shadow Generator and the declaration you copy will match the preview you approved. If you are rebuilding pages in a wider cleanup, our guide to converting HTML to Markdown covers moving the content itself into a cleaner format. For more guides in this series, see our Website and Webmaster Tools guides.

References