CSS box-shadow Property
Adds one or more shadow effects to an element's frame
Syntax
box-shadow: none | <offset-x> <offset-y> <blur>? <spread>? <color>? [inset]?;Values
| Value | Description |
|---|---|
| none | No shadow (default) |
| 0 1px 3px rgba(0,0,0,0.12) | Subtle shadow |
| 0 4px 6px -1px rgba(0,0,0,0.1) | Medium shadow |
| 0 20px 25px -5px rgba(0,0,0,0.25) | Large shadow |
| inset 0 2px 4px rgba(0,0,0,0.1) | Inner shadow |
Example
.card {
box-shadow:
0 1px 3px rgba(0, 0, 0, 0.1),
0 1px 2px rgba(0, 0, 0, 0.06);
}
.card:hover {
box-shadow:
0 10px 15px -3px rgba(0, 0, 0, 0.2);
}Understanding CSS box-shadow
The CSS box-shadow property adds one or more shadow effects to an element's frame. As part of the Filter & Effects module in CSS, it is one of the most commonly used properties for controlling the visual presentation of web pages.
You can set box-shadow to values such as none, 0 1px 3px rgba(0,0,0,0.12), 0 4px 6px -1px rgba(0,0,0,0.1), 0 20px 25px -5px rgba(0,0,0,0.25), among others. Each value changes how the browser renders the affected element, giving you fine-grained control over your page layout and design. Choosing the right value depends on the specific design requirements of your project.
Common use cases for the box-shadow property include responsive web design, component-based layouts, and creating visually consistent interfaces across devices. It works closely with related properties like text-shadow, filter, border to achieve complex styling effects. Understanding how these properties interact helps you write cleaner, more maintainable stylesheets.
Browser support for box-shadow is excellent across all modern browsers including Chrome, Firefox, Safari, and Edge. For older browsers, consider using fallback values or progressive enhancement strategies. The property can also be set dynamically via JavaScript using element.style.boxShadow or the CSS custom properties (variables) approach for theming.
Related Properties
Explore More CSS Properties
Browse our complete reference of 251 CSS properties with syntax, examples, and tips.