Skip to main content

CSS Box Shadow

Generate CSS box-shadows visually.

Controls

10px
10px
5px
0px
0.50
#000000

Preview

Preview

CSS Code

box-shadow: 10px 10px 5px 0px rgba(0, 0, 0, 0.5);
Share:

Mastering CSS Shadows

Shadows are more than just decoration; they provide essential visual cues about depth, hierarchy, and interaction in user interfaces. A well-crafted shadow can make an element pop off the screen.

A black and white cartoon of floating paper layers, each casting a shadow on the one below it to show depth.A black and white cartoon of floating paper layers, each casting a shadow on the one below it to show depth.

Understanding the Properties

The `box-shadow` property is composed of several values that control the position, size, and quality of the shadow.

Offset (X & Y)

Moves the shadow horizontally and vertically. Positive values move right/down, negative move left/up.

Blur Radius

Determines how sharp or soft the shadow edge is. Higher values mean a bigger, lighter blur.

Spread Radius

Expands or shrinks the shadow size. Positive values make it larger than the element, negative make it smaller.

Inset

Changes the shadow from an outer drop shadow to an inner shadow, as if the content is depressed inside the box.

Pro Tips for Better Shadows

  • Less is more. Subtle, semi-transparent shadows often look more professional than dark, harsh ones.
  • Layer multiple shadows to create complex, realistic depth effects (e.g., one for ambient light, one for direct light).
  • Avoid pure black shadows. Use a dark shade of your background or primary color for a more natural look.
A black and white cartoon of a light bulb shining on a cube, casting a realistic shadow that demonstrates the physics of light.A black and white cartoon of a light bulb shining on a cube, casting a realistic shadow that demonstrates the physics of light.

Learn More

Dive deeper into the syntax and browser support at MDN Web Docs.