CSS & Web Design

How to Create a CSS Box Shadow: Step-by-Step Guide

The Syntax

box-shadow: offset-x offset-y blur-radius spread-radius color;

Blur and spread are optional; color defaults to the element's text color if left out entirely, though it's best practice to always specify it explicitly.

What Each Value Controls

Step-by-Step

  1. Set the offset to establish the shadow's direction.
  2. Adjust blur until the edge softness looks right.
  3. Adjust spread if you want the shadow larger or tighter than the element itself.
  4. Pick a translucent color rather than solid black for a more natural look.
  5. Copy the generated CSS into your stylesheet.

The Inset Keyword

Adding inset before the color flips the shadow to render inside the element's border instead of outside it, creating a recessed, pressed-in look rather than a raised, elevated one.

Ready to build your own shadow visually?

Try the Box Shadow Generator