A box-shadow value looks like a string of numbers that fell off a truck: 0px 8px 24px 0px rgba(0, 0, 0, 0.2). Each value is a separate decision: where the shadow sits, how big it is, how soft its edge is, what color it is, and they always appear in the same order.

This guide reads that syntax value by value, using the free Box Shadow Generator on Ovatly to make each abstract number visible. By the end, you will be able to look at any shadow declaration and say exactly what each part is doing.

Contents

  • Quick answer
  • The five values, in order
  • Reading the example declaration, value by value
  • Modifier one: inset turns the shadow inward
  • Modifier two: negative spread pulls the shadow in
  • Why one shadow rarely looks natural
  • How to build a shadow in the generator, step by step
  • Limitations and honest tradeoffs
  • Common mistakes
  • FAQs
  • Conclusion
  • References

Quick answer

A box-shadow value is written as: horizontal offset, vertical offset, blur radius, spread radius, color. The offsets position the shadow relative to the box, blur softens its edge, spread grows or shrinks it, and the color sets its tint and opacity. The keyword inset flips the shadow inside the box. Build and read shadows layer by layer in the Box Shadow Generator, and copy the finished declaration when the stack looks right.

The five values, in order

Horizontal offset. How far the shadow shifts sideways. Positive values move it right, negative values left, and 0 keeps it centered under the box. Most natural shadows use 0 here: light rarely comes from the side.

Vertical offset. How far the shadow shifts up or down. A positive value puts the shadow below the element, which reads as light coming from above.

Blur radius. How soft the shadow's edge is. A radius of 0 draws a hard offset copy of the box. Larger values feather the edge further. Blur can never be negative.

Spread radius. How much the shadow grows or shrinks before the blur is applied. Positive spread makes it bigger than the box on all sides; negative spread pulls it in smaller, so it hides behind the element except where the offsets push it out.

Color. The shadow's tint, written with an opacity so it blends with whatever sits beneath it. A pure black at full opacity looks like a cutout, not shade; real shadows are partial, which is why the generator emits the color as rgba().

Reading the example declaration, value by value

The generator's example is one layer with offsets of 0px and 8px, a blur of 24px, a spread of 0px, and the color #000000 at 20% opacity. It produces:

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

The first 0px: the shadow does not shift sideways. The 8px: it sits 8 pixels below the box, so the element reads as floating above the surface. The 24px blur: a generous feather, so the edge is a gradient rather than a line. The 0px spread: the shadow starts exactly the size of the box before blurring, neither swollen nor shrunk. Finally rgba(0, 0, 0, 0.2): black at one fifth opacity, dark enough to register, light enough to show the background through. Change any one value and only that one quality changes.

Modifier one: inset turns the shadow inward

Everything above describes a shadow cast outward onto the page. Add the inset keyword, or flip the inset toggle on a layer in the generator, and the same values draw the shadow inside the element's border instead. The effect reads as depth going down rather than height going up: a pressed button, a recessed input field. It is the same syntax with the illusion reversed, which is why inset pairs naturally with regular shadows: raised at rest, inset when pressed.

Modifier two: negative spread pulls the shadow in

Spread is the value beginners ignore, and its negative half is the most useful trick in the syntax. With spread at 0 or above, a blurred shadow leaks out on every side of the box, including the top, even when the offset pushed it downward. A negative spread shrinks the shadow first, so after offset and blur it shows only where you meant it to: beneath the element, not glowing around all four edges. Remember the asymmetry: spread may be negative, blur may not. Wanting a negative blur usually means you want less spread and a smaller offset.

Why one shadow rarely looks natural

Real objects shade a surface in two ways. Directly beneath the object there is a tight, darker core where light is fully blocked. Around it spreads a wide, faint halo where the light is only partly blocked. A single layer forces a choice, and either looks staged: core alone looks like a sticker, halo alone looks like a glow.

The generator builds shadows layer by layer, up to four layers on one element, so you can stack both. Use a small offset, a small blur and a stronger opacity for the core, then a larger offset, a large blur and a weak opacity for the halo. Two honest layers beat one compromised one, and the remaining layers are there for effects such as an inset press state.

How to build a shadow in the generator, step by step

  1. Open the Box Shadow Generator and start with one layer. Set the vertical offset first; it decides how high the element floats.
  2. Set the blur to roughly two to three times the offset for a soft edge, and leave spread at 0 until the shape reads correctly.
  3. Set the color to black and lower the opacity until the shadow looks like shade rather than a shape.
  4. Add a second layer for whichever of core or halo the first layer is not doing, and compare.
  5. Copy the finished declaration. The layers are emitted as one comma-separated box-shadow value.

Limitations and honest tradeoffs

The generator builds the declaration; it cannot judge your page. A shadow that looks right against the preview can be too strong on a busy background or invisible on a dark one, because the color blends with whatever sits beneath the element. Judge the pasted result in place, not the preview alone.

Four layers is the ceiling here: shadows beyond two or three layers are almost always effects rather than realism, and each added layer costs readability of the code. The generator also cannot enforce consistency: a site where every card invents its own offset and blur looks restless, and keeping a small set of shadow values is a discipline of yours, not the tool's.

Common mistakes

  • Reading the values in the wrong order. Blur and spread sit side by side and do opposite kinds of work: swap them and a soft shadow turns into a swollen hard one.
  • Full-opacity black. A shadow at 100% black is a silhouette. Real shade is partial: lower the opacity first.
  • Huge offset, tiny blur. The shadow detaches and reads as a second object. Keep blur in proportion to offset.
  • Shadow leaking on all sides. If a drop shadow glows above the element too, the fix is negative spread, not a smaller blur.
  • One shadow for every state. A resting card and a pressed button are opposite illusions: pressed means inset, and copying the resting shadow onto it flattens the interaction.

FAQs

What order do the box-shadow values go in? Horizontal offset, vertical offset, blur radius, spread radius, then color: 0px 8px 24px 0px rgba(0, 0, 0, 0.2) means no sideways shift, 8px down, a 24px blur, no spread, and black at 20% opacity. The optional inset keyword changes where the shadow is drawn.

What does a negative spread do? It shrinks the shadow smaller than the box, concentrating it under the element instead of letting it peek out on all sides. Spread is the only size value allowed to go negative: blur can never be negative.

What does a blur radius of 0 look like? A hard-edged copy of the box, offset by the offset values. It reads as a flat graphic offset rather than a shadow, which is sometimes the intent.

How many shadows can one element have? In the Box Shadow Generator, up to four layers on one element, each fully independent. Two layers cover most realistic cases: a tight dark core and a wide soft halo.

What does inset do to a box shadow? It draws the shadow inside the element's border instead of outside it, so the edges shade inward: the standard way to make a control look pressed in or recessed.

Conclusion

Box shadow syntax stops being intimidating once you read it as a sentence: where the shadow sits, how soft it is, how big it is, and what color, with inset and negative spread as the two modifiers that change its character. The Box Shadow Generator makes each value visible as you change it, and emits the finished declaration. Shadows earn their keep when the colors underneath behave too, so if your elements sit on a gradient, our guide to picking gradient colors that do not clash covers the pairing rules that keep the background calm. For more guides in this series, see our Website and Webmaster Tools guides, which pair each technique with the free tool that performs it.

References