Skip to content
en

Box-shadow generator

Builds a ready box-shadow line: offset, blur, spread, color and opacity. Shows how far the shadow reaches past the element and whether it shows at all.

Input

#000000

Result

Fill in the fields – the result will appear here.

Report a problem
This will be sent with your message:
Advertisement

How the box-shadow property works

Five values in a fixed order

box-shadow: 0 4px 12px 0 rgba(0, 0, 0, 0.25); means X offset, Y offset, blur, spread and color. The order can't change: the browser reads the numbers by position, not by meaning. The first two are required, the rest are not.

Offset

A positive X moves the shadow right, a positive Y moves it down. A downward shadow looks natural because in a usual scene light falls from above. Zero offset with blur gives an even glow around the element.

Blur is split in half

This is where people most often get it wrong. A 12 pixel blur does not mean the shadow reaches 12 pixels further: half of the blur falls inside the shadow's edge, half outside. So the real reach past the edge is the offset plus six, plus spread.

Spread

Grows the shadow on every side before the blur is applied. A negative value shrinks it – that's how a narrow dense shadow under a card is made.

Color and opacity

Almost always this is black at low opacity, not grey. Grey stays grey on any background, while semi-transparent black picks up the color of what's under it, so it looks like a real shadow.

Inner shadow

The word inset before the numbers turns the shadow inward: the element looks pressed in. Such a shadow never goes past the edge, so it has no "reach past the edge".

Common questions about CSS shadows

Does a shadow take space on the page?

No. Neighbouring elements don't see it and don't move aside – the shadow can overlap what's next to it. If you need a gap, use a margin, not a shadow.

Why is my shadow not visible?

Three common reasons: zero opacity, zero offset and blur (then the shadow is fully behind the element), or overflow: hidden on the parent, which clips it.

How many shadows can I stack?

As many as you like – separated by commas, and the first in the list is drawn closest to the reader. Layered shadows give softer depth than one big one. This page builds one layer; more layers are just added with a comma.

box-shadow or filter: drop-shadow?

box-shadow draws a rectangle following the border's shape. drop-shadow follows the real shape – the outline of a transparent PNG or an SVG. For a rounded card use the first, for an icon with cut-outs the second.

And a shadow for text?

That's a different property – text-shadow, and it has no spread: only offset, blur and color.

Advertisement

Report a problem

This will be sent with your message: