box-shadow Propertybox-shadow is a CSS property that adds shadow effects around an element's frame. It can create depth, highlight elements, and add visual interest. You can apply multiple shadows, control their color, blur, spread, and even make them appear inside the element (inset).
The box-shadow property is not limited to
rectangles—when used on elements with border-radius (such
as circles or rounded cards), the shadow follows the shape of the
element, enabling effects like glows, soft drop shadows, and even
simulating natural phenomena like a lunar eclipse. Shadows can be
layered for realism, and inset shadows can create the illusion of
depth within the element itself. Experimenting with color, blur, and
spread can help you achieve subtle or dramatic effects, making
box-shadow a versatile tool for modern UI design.
box-shadow: h-offset v-offset blur spread color [inset];
Multiple shadows can be added by separating each with a comma. Shadows are rendered front-to-back (first is on top).
.basic-shadow {
box-shadow: 4px 4px 12px #888;
}
.colored-shadow {
box-shadow: 0 8px 24px 0 rgba(52, 152, 219, 0.4);
}
.inset-shadow {
box-shadow: inset 0 2px 8px 0 #8e44ad;
}
.multiple-shadow {
box-shadow: 2px 2px 8px #3498db, 0 0 0 4px #fff, 0 8px 24px 0 rgba(52,152,219,0.2);
}
.interactive-shadow:hover {
box-shadow: 0 8px 32px 0 #f7971e, 0 0 0 4px #ffd200;
}
.eclipse-shadow {
border-radius: 50%;
box-shadow: 24px 0 40px -8px #23272e, -8px 0 24px 0 #ffd200;
}