What box-shadow does

Quick answer: the CSS box-shadow property draws a shadow behind — or, with the inset keyword, inside — an element. A value lists four lengths in order (horizontal offset, vertical offset, blur radius, spread radius) followed by a colour, as in 0px 4px 12px 0px rgba(0, 0, 0, 0.25).

Shadows are how flat web pages suggest depth. A card with a soft shadow appears to float a few millimetres above the page; a modal with a stronger one sits above everything else. Before box-shadow, designers faked this with sliced background images. The property does it in one line of CSS, scales to any element size, and costs no image downloads — which is why it sits underneath almost every card, dropdown and dialog on the modern web.

The anatomy of the value

Every box-shadow value is built from the same parts, always in the same order. Only the two offsets are required; the rest have defaults.

PartWhat it controls
Offset XHorizontal shift — positive moves the shadow right, negative moves it left
Offset YVertical shift — positive moves the shadow down, negative moves it up
Blur radiusHow far the shadow's edge softens; 0 gives a hard, solid copy of the box
Spread radiusHow much the shadow grows or shrinks before the blur is applied
ColourThe shadow's colour and, through rgba(), its transparency
insetOptional keyword — draws the shadow inside the element instead of outside

This generator writes the colour last and uses pixels throughout. CSS also allows the colour first, and any length unit — em, rem and the rest — so you can adapt the copied value to your own stylesheet's conventions.

How to use this generator, step by step

Start from a preset if one is close to what you need, or keep the Medium default. Drag the Horizontal and Vertical Offset sliders to position the shadow — for a natural light-from-above look, the vertical offset does most of the work. Set the Blur Radius for softness and the Spread Radius for size, then pick a colour and lower the Opacity until the shadow looks like a shadow rather than a grey smudge; most real-world card shadows live between 8% and 30% opacity. Tick Inset if the shadow should sit inside the element. The preview card carries exactly the generated shadow at all times, and the code box below it always shows the matching declaration — when it looks right, copy it.

Blur cannot be negative — but spread can

One control on this page behaves differently from the others, and it is deliberate. A negative blur radius is invalid CSS: write one by hand and the browser discards the whole declaration, so the blur slider starts at 0. Spread has no such rule. A positive spread makes the shadow's shape bigger than the element before blurring; a negative spread makes it smaller, concentrating a wide blur close to the edges. That combination — big blur, negative spread — is the standard trick behind the soft, tight shadows on modern cards, and it is exactly what the Soft Large preset uses: 48 pixels of blur pulled in by −12 of spread.

Colour and opacity: hex or rgba()

The generator follows one documented rule for the colour. Below 100% opacity, the colour is written as rgba() with the alpha rounded to two decimals — 25% becomes 0.25. At exactly 100% opacity there is no transparency to express, so it writes the plain lowercase hex value instead. Neither form is more correct; rgba() is simply the only one of the two that can carry transparency. Pure black at low opacity is the safe default, but a shadow tinted with your page's own dark tone — a very dark blue or brown — usually looks more natural than neutral grey-black.

Starting points: the four presets

Each preset is only a set of slider values, printed in full next to the preset buttons — nothing is applied behind your back.

PresetValues (X / Y / Blur / Spread, opacity)Typical use
Subtle0 / 2 / 8 / 0, 10%List items, table rows, quiet cards
Medium0 / 4 / 12 / 0, 25%Everyday content cards
Strong0 / 10 / 24 / 0, 40%Modals, popovers, dropdown menus
Soft Large0 / 24 / 48 / −12, 18%Hero panels and floating banners

Browser support and honest limits

The standard box-shadow property works unprefixed in all modern browsers — Chrome, Firefox, Safari and Edge — and has for well over a decade, so the copied CSS needs no vendor prefixes. Two limits are worth knowing. First, this tool generates one shadow at a time; CSS allows several comma-separated shadows on one element, and the FAQ explains how to combine values by hand. Second, very large blur radii on very large elements are among the more expensive things a browser paints, and animating a shadow repaints it every frame — for animated elements, transitioning opacity of a pre-shadowed layer is usually smoother.

Sources