bugl
bugl
HomeLearnPatternsPathsSearchPremium
HomeLearnPatternsPaths
Learn/CSS/Advanced Styling
CSS•Advanced Styling

CSS Box Shadow

CSS box-shadow Property

The CSS box-shadow property is used to apply one or more shadows to an element.

Box shadow

In its simplest use, you can only specify the horizontal and the vertical offset of the shadow.

In addition, you can add a shadow color, a spread radius, a blur effect, and change the shadow from an outer shadow to an inner shadow (inset).

CSS Horizontal and Vertical Shadow

In its simplest use, you only specify the horizontal and the vertical offset of the shadow.

The default color of the shadow is the current text color.

Example

Formatted code
div {
  box-shadow: 10px 10px;
}

Live preview

Specify a Color for the Shadow

The color parameter defines the color of the shadow.

Example

Formatted code
div {
  box-shadow: 10px 10px lightblue;
}

Live preview

Add a Blur Effect to the Shadow

The blur parameter defines the blur radius of the shadow. The higher the number, the more blurred the shadow will be.

Example

Formatted code
div {
  box-shadow: 10px 10px 5px lightblue;
}

Live preview

Set the Spread Radius of the Shadow

The spread parameter defines the spread radius of the shadow.

A positive value increases the size of the shadow, and a negative value decreases the size of the shadow.

Example

Formatted code
div {
  box-shadow: 10px 10px 5px 12px lightblue;
}

Live preview

Set the inset Parameter

The inset parameter changes the shadow from an outer shadow (outset) to an inner shadow (inside an element's frame).

Example

Formatted code
div {
  box-shadow: 10px 10px 5px lightblue inset;
}

Live preview

Add Multiple Shadows

An element can also have multiple shadows.

To attach more than one shadow to an element, add a comma-separated list of shadows.

Example

Formatted code
div {
  box-shadow: 5px 5px 8px blue, 10px 10px 8px red, 15px 15px 8px green;
}

Live preview

Creating Shadow Cards

You can also use the box-shadow property to create paper-like cards:

CSS Shadow Properties

The following table lists the CSS shadow properties:

PropertyDescription
box-shadowAdds one or more shadows to an element
text-shadowAdds one or more shadows to a text

Previous

CSS Shadow Effects

Next

CSS Text Effects

This chapter

Overview
53

Lessons

154m

Read time

1. CSS Rounded Corners2. Sass Tutorial3. CSS Border Images4. CSS Multiple Backgrounds5. CSS Background Size6. CSS Background Origin7. CSS Background Clip8. CSS Colors9. CSS Color Keywords10. CSS Gradients11. CSS Radial Gradients12. CSS Conic Gradients13. CSS Shadow Effects14. CSS Box Shadow15. CSS Text Effects16. CSS Custom Fonts17. CSS 2D Transforms18. CSS 2D Transform Scale19. CSS 2D Transform Skew / Matrix20. CSS 3D Transforms21. CSS Transitions22. CSS Transition Timing23. CSS Animations24. CSS Animation Timing25. CSS Animation Properties26. CSS Tooltip27. CSS Tooltip Arrows28. CSS Styling Images29. CSS Image Effects30. CSS Image Hover Overlays31. CSS Responsive Modal Images32. CSS Centering Images33. CSS Image Filter Effects34. CSS Image Shapes35. CSS object-fit Property36. CSS object-position Property37. CSS Masking38. CSS Gradient Mask Layers39. CSS SVG Mask Layers40. CSS Styling Buttons41. CSS Button Hover Effects42. CSS Button Groups43. CSS Pagination Styles44. CSS Multiple Columns45. CSS Column Rules46. CSS User Interface47. CSS Variables - var() Function48. CSS Overriding Variables49. CSS Variables and JavaScript50. CSS Variables in Media Queries51. CSS @property Rule52. CSS Box Sizing53. CSS Media Queries

On this page

CSS box-shadow PropertyCSS Horizontal and Vertical ShadowSpecify a Color for the ShadowAdd a Blur Effect to the ShadowSet the Spread Radius of the ShadowSet the inset ParameterAdd Multiple ShadowsCreating Shadow CardsCSS Shadow Properties