CSS box-shadow Property
Description
The box-shadow property is used to paint one or more shadows around an element’s frame, creating depth and separation from the page background. Unlike borders, shadows do not change layout or the element’s box dimensions; they are purely visual and are composited on top of or beneath the element’s background. You can layer multiple shadows to build subtle depth or dramatic emphasis, and shadows may be applied so they appear to emanate from outside the element or to appear contained within it, resulting in different visual effects.
Shadows interact with an element’s rounded corners and background filling: a clipped corner will produce a shadow that follows the curved edge, so combining border-radius with shadows is a common way to create soft, card-like surfaces. Because shadows are painted relative to an element’s box, they also work together with the element’s background to define perceived depth; a semi-transparent background color plus a gentle shadow can convey elevation, while a strong shadow against a light background gives a floating appearance. When elements are transformed (rotated, scaled, or translated), their shadows are transformed along with them, so consider the visual relationship between an element and its shadow when using transform.
Rendering and performance are important considerations when using shadows extensively. Complex or large shadows can increase paint and compositing work, especially when many elements or frequent animations are involved; in such cases it’s common to use a compositing hint like will-change or to render a shadow via a rasterized asset or pseudo-element to reduce repeated repaints. An alternative for some use cases is to use image-based or filtered effects - for instance the CSS drop-shadow via filter - which can sometimes be cheaper or offer different blending characteristics than native box shadows.
From a practical design standpoint, subtlety usually works best: mild, low-contrast shadows provide separation without overpowering content, while larger, higher-contrast shadows should be used sparingly for emphasis. Shadows should not be relied on as the only indicator for interactive focus or state; pair them with clear focus outlines or other cues such as color changes and borders - for focus outlines consider outline - and be mindful of stacking contexts and layering when overlapping elements (which is controlled in part by z-index). Finally, consider accessibility and color contrast: very subtle shadows may be invisible to some users or on certain displays, so test designs across backgrounds and devices.
Definition
- Initial value
- none
- Applies to
- All elements
- Inherited
- No
- Computed value
- Any <length> made absolute; any specified color computed; otherwise as specified
- Animatable
- Yes
- JavaScript syntax
- object.style.boxShadow
Interactive Demo
Syntax
box-shadow: none | <shadow> [ , <shadow> ]*
Values
- 1st <length>Specifies the horizontal offset of the shadow. A positive value draws a shadow that is offset to the right of the box, a negative length to the left.
- 2nd <length>Specifies the vertical offset of the shadow. A positive value offsets the shadow down, a negative one up.
- 3rd <length>Specifies the blur radius. Negative values are not allowed. If the blur value is zero, the shadow's edge is sharp. Otherwise, the larger the value, the more the shadow's edge is blurred.
- 4th <length>Specifies the spread distance. Positive values cause the shadow to expand in all directions by the specified radius. Negative values cause the shadow to contract.
- <color>Specifies the color of the shadow. If the color is absent, the used color is taken from the 'color' property.
- insetIf present, the 'inset' keyword changes the drop shadow from an outer box-shadow (one that shadows the box onto the canvas, as if it were lifted above the canvas) to an inner box-shadow (one that shadows the canvas onto the box, as if the box were cut out of the canvas and shifted behindit).
Example
Browser Support
The following information will show you the current browser support for the CSS box-shadow property. Hover over a browser icon to see the version that first introduced support for this CSS property.
This property is supported by all modern browsers.
Desktop
Tablets & Mobile
Last updated by CSSPortal on: 1st January 2026
