--- url: "https://web.dev/learn/css/shadows" titulek: "Shadows | web.dev" h1: "Shadows Stay organized with collections Save and categorize content based on your preferences." popis: "There are a number of ways to add shadows to text and elements in CSS. In this module you'll learn how to use each option, and the tasks they were designed for." jazyk: "en" kanonicka: "https://web.dev/learn/css/shadows" drobecky: ["web.dev", "Resources", "CSS"] zdroj: "live" wayback_snapshot: "" stazeno: "2026-09-13 21:36:13" znaku: 6091 slov: 1017 kodovani: "iso-8859-2" sha256: "9412f5f72f96bc93b7b970dee7b09eb5f406a440be2787c45871f07f99535382" --- Shadows Stay organized with collections Save and categorize content based on your preferences. [The CSS Podcast - 017: Shadows](https://thecsspodcast.libsyn.com/017-shadows) Say you've been sent a design to build and in that design there's a picture of a t-shirt, cut out, with a drop shadow. The designer tells you that the product image is dynamic and can be updated via the content management system, so the drop shadow needs to be dynamic too. Instead of a t-shirt, the image could be a visor or shorts, or any other item. How do you do that with CSS? CSS has the [`box-shadow`](https://developer.mozilla.org/docs/Web/CSS/box-shadow) and [`text-shadow`](https://developer.mozilla.org/docs/Web/CSS/text-shadow) properties, but the picture isn't text, so you can't use `text-shadow`. If you use `box-shadow`, the shadow is on the surrounding box, *not* around the t-shirt. Luckily, there is another option: the [`drop-shadow()`](https://developer.mozilla.org/docs/Web/CSS/filter-function/drop-shadow()) filter. This enables you to do exactly what the designer asked for. There are plenty of options when it comes to shadows in CSS, each designed for a different use case. Box shadow Browser Support 10 12 4 5.1 [Source](https://developer.mozilla.org/docs/Web/CSS/Reference/Properties/box-shadow) The `box-shadow` property is for adding shadows to the box of an HTML element. It works on block elements and inline elements. `.my-element { box-shadow: 5px 5px 20px 5px #000; }` The order of values for `box-shadow` are as follows: **Horizontal offset**: a positive number pushes it out from the left and a negative number will push it out from the right. **Vertical offset**: a positive number pushes it down from the top, and a negative number will push it up from the bottom. **Blur radius**: a larger number produces a more blurred shadow, whereas a small number produces a sharper shadow. **Spread radius** (optional): a larger number increases the size of the shadow and a smaller number decreases it, making it the same size as the **blur radius** if it's set to 0. **Color**: [Any valid color value](/learn/css/color). If this isn't defined, the computed text color will be used. To make a box shadow an inner shadow, rather than the default outer shadow, add an `inset` keyword **before** the other properties. `/* Outer shadow */ .my-element { box-shadow: 5px 5px 20px 5px #000; } /* Inner shadow */ .my-element { box-shadow: inset 5px 5px 20px 5px #000; }` Multiple shadows You can add as many shadows as you like with `box-shadow`. Add a comma separated collection of value sets to achieve this: `.my-element { box-shadow: 5px 5px 20px 5px darkslateblue, -5px -5px 20px 5px dodgerblue, inset 0px 0px 10px 2px darkslategray, inset 0px 0px 20px 10px steelblue; }` Properties affecting box-shadow Adding a `border-radius` to your box will also affect the shape of the box shadow. This is because CSS is creating a shadow based on the shape of the box as if light is pointing at it. `.my-element { box-shadow: 0px 0px 20px 5px darkslateblue; border-radius: 25px; }` If your box with `box-shadow` is in a container that has `overflow: hidden`, the shadow **won't** break out of that overflow either. `