Why add shadows to images?
A shadow makes an image look like it's sitting slightly above the page, like a printed photo resting on a table. A well-chosen shadow adds depth, draws the eye, and separates images from the background around them.
In this post we've put together ten image shadows you can copy into your own projects. They range from subtle, everyday shadows to eye-catching effects like curled corners and stacked photos. All of them use CSS alone, with no image editing needed.
Here's a preview of three of them:
How box-shadow works
Most of our shadows use the box-shadow property. It draws a shadow around an element's box and takes up to five values, plus an optional keyword:
box-shadow: 0 8px 16px -4px rgb(0 0 0 / 0.25);
/* x y blur spread colour */
| Value | What it does |
|---|---|
| Horizontal offset (x) | Moves the shadow right (positive) or left (negative) |
| Vertical offset (y) | Moves the shadow down (positive) or up (negative) |
| Blur radius | How soft the edge is. 0 gives a hard, sharp shadow. |
| Spread radius | Grows (positive) or shrinks (negative) the shadow before blurring. Optional. |
| Colour | Usually black with transparency, such as rgb(0 0 0 / 0.25) |
inset | Optional keyword that draws the shadow inside the box instead of outside |
You can also list several shadows, separated by commas, and they'll be layered on top of each other. That's the secret to many realistic-looking shadows.
Tip: real shadows are rarely solid black. A colour like rgb(0 0 0 / 0.25), black at 25% strength, lets the background show through and looks far more natural.
The setup
Every example uses the same simple HTML: an image inside a wrapper.
<div class="photo">
<img src="landscape.jpg" alt="Green hills under a sunny sky">
</div>
And this base CSS, which gives each image a white frame like a printed photo:
.photo {
position: relative;
isolation: isolate;
display: inline-block;
}
.photo img {
display: block;
position: relative;
padding: 8px;
background: #ffffff;
border: 1px solid #e5e7eb;
}
Why the wrapper?
Some of our shadows are drawn with the ::before and ::after pseudo-elements, extra boxes added with CSS. Images can't have pseudo-elements, so we add them to the wrapper instead.
Those extra boxes need to sit behind the image, so we give them z-index: -1. On its own, that could send them behind the whole page, where they'd disappear. isolation: isolate on the wrapper stops that by creating a new stacking context: a self-contained layer, so "behind" means behind the image, but still in front of the page.
What changed since the old version? The original examples used z-index: -2 without isolating the wrapper. Depending on the page around them, the shadows could vanish behind a background. isolation: isolate makes them reliable anywhere.
Shadows 1 to 3: simple box shadows
These three need nothing more than box-shadow on the image.
Shadow 1: Soft card
A small, subtle shadow that lifts the image just off the page. It's the kind you'll see on cards and thumbnails all over the web. Two layers combine: a soft, wider one and a tighter, darker one closer to the edge.
.photo--soft img {
box-shadow: 0 1px 3px rgb(0 0 0 / 0.12),
0 1px 2px rgb(0 0 0 / 0.24);
}
Shadow 2: Layered depth
Stacking three shadows of increasing size and blur creates a smooth, realistic shadow, like the image is floating well above the page. Each layer is very faint on its own; together they look natural.
.photo--layered img {
box-shadow: 0 2px 4px rgb(0 0 0 / 0.06),
0 8px 16px rgb(0 0 0 / 0.08),
0 24px 48px rgb(0 0 0 / 0.12);
}
Shadow 3: Bottom edge
A shadow that only appears along the bottom edge. The trick is a large negative spread, which shrinks the shadow so it hides behind the image, combined with a big downward offset, which pushes just a sliver out at the bottom.
.photo--bottom img {
box-shadow: 0 28px 16px -26px rgb(0 0 0 / 0.6);
}
Correction: the original version of this shadow used rgba(0, 0, 0), with only three numbers. Older browsers required a fourth number for transparency in rgba(), so the whole shadow was ignored. The modern rgb(0 0 0 / 0.6) works everywhere.
Shadows 4 to 7: pseudo-element shadows
These shadows use ::before and ::after on the wrapper to draw extra shapes behind the image. That lets us create shadows that aren't simple rectangles.
Shadow 4: Lifted corners
The bottom corners look like they're curling up off the page. Two invisible boxes sit behind the bottom of the image, each tilted slightly outwards. Only their shadows peek out below the corners.
.photo--lifted::before,
.photo--lifted::after {
content: "";
position: absolute;
z-index: -1;
bottom: 16px;
width: 48%;
height: 20%;
box-shadow: 0 18px 12px rgb(0 0 0 / 0.5);
}
.photo--lifted::before {
left: 8px;
rotate: -6deg;
}
.photo--lifted::after {
right: 8px;
rotate: 6deg;
}
Tip: increase the rotation angle (try 9deg) for a stronger curl, or reduce it (try 3deg) for a gentle one.
Shadow 5: Curved shadow
A soft shadow that wraps around the sides and bottom, curving inwards as if the photo is slightly bent. The pseudo-element covers the lower half of the image and uses an elliptical border-radius, so its blurred shadow takes on a curved shape.
.photo--curved::before {
content: "";
position: absolute;
z-index: -1;
top: 50%;
bottom: 0;
left: 6px;
right: 6px;
border-radius: 100px / 10px;
box-shadow: 0 0 20px rgb(0 0 0 / 0.8);
}
border-radius: 100px / 10px sets two different curves: 100px across and 10px up and down. That creates long, flat ovals at the corners instead of round ones.
Shadow 6: Floating
The image hovers above the page, with a soft oval shadow on the "ground" underneath it. Instead of a box shadow, this uses a radial-gradient, a background that fades outwards from the centre, which gives a beautifully soft edge.
.photo--floating {
margin-bottom: 30px; /* room for the shadow */
}
.photo--floating::after {
content: "";
position: absolute;
z-index: -1;
left: 8%;
right: 8%;
bottom: -30px;
height: 20px;
border-radius: 50%;
background: radial-gradient(closest-side, rgb(0 0 0 / 0.35), transparent);
}
closest-side makes the gradient fade out exactly at the edges of the oval, so there's no hard line anywhere.
Shadow 7: Stacked photos
A small pile of photos, with the image on top. Two pseudo-elements create blank "photos" the same size as the frame, each rotated a few degrees so their edges show.
.photo--stacked::before,
.photo--stacked::after {
content: "";
position: absolute;
z-index: -1;
inset: 0;
background: #ffffff;
border: 1px solid #e5e7eb;
box-shadow: 0 1px 4px rgb(0 0 0 / 0.15);
}
.photo--stacked::before {
rotate: -4deg;
}
.photo--stacked::after {
rotate: 3deg;
}
inset: 0 is shorthand for top, right, bottom and left all set to 0, so each extra photo exactly matches the wrapper's size.
Shadows 8 to 10: creative shadows
Shadow 8: Coloured glow
Shadows don't have to be grey. A coloured shadow gives a soft glow that suits bright, modern designs. The negative spread keeps the glow tucked under the image, so it spills out mostly at the bottom.
.photo--glow img {
border-color: transparent;
border-radius: 12px;
box-shadow: 0 12px 32px -8px rgb(29 78 216 / 0.55);
}
Tip: try picking the glow colour from the image itself, such as a blue from the sky or a warm orange from a sunset. It makes the shadow feel like part of the photo.
Shadow 9: Hard offset
A bold, retro look with no blur at all. Setting the blur to 0 gives a crisp, solid block of colour offset to the side, popular in playful, poster-style designs.
.photo--offset img {
border: 2px solid #111827;
box-shadow: 8px 8px 0 #1d4ed8;
}
Shadow 10: Drop shadow for cut-out images
box-shadow always follows the element's rectangular box. That's a problem for images with transparent backgrounds, such as a logo or a product cut-out: you get a square shadow around a round or irregular shape.
The drop-shadow() filter solves this. It follows the visible shape of the image, ignoring transparent areas:
.cutout--box { box-shadow: 4px 8px 12px rgb(0 0 0 / 0.35); }
.cutout--drop { filter: drop-shadow(4px 8px 6px rgb(0 0 0 / 0.35)); }
Notice that drop-shadow() has no spread value and doesn't support inset, and its blur looks a little stronger than the same number in box-shadow. Use a slightly smaller blur to get a similar softness.
Tips for better shadows
Pick one light source
In real life, shadows all fall the same way because the light comes from one direction. Keep your shadow offsets consistent across a page, usually pointing down and slightly to one side, and your design will feel more natural.
Animate shadows on hover
A shadow that grows when you hover makes an image feel like it's lifting towards you. Pair it with a small upward move:
.photo img {
box-shadow: 0 1px 3px rgb(0 0 0 / 0.12);
transition: translate 0.25s ease, box-shadow 0.25s ease;
}
.photo:hover img {
translate: 0 -4px;
box-shadow: 0 2px 4px rgb(0 0 0 / 0.06),
0 12px 24px rgb(0 0 0 / 0.12);
}
As with any animation, switch it off for visitors who've turned on "reduce motion" in their device settings, using @media (prefers-reduced-motion: reduce).
Keep it subtle
A shadow should support the image, not compete with it. If people notice the shadow before the photo, it's probably too strong. Lower the opacity of the colour first; it's usually the quickest fix.
Think about dark backgrounds
Dark shadows barely show on a dark page. On dark designs, try a lighter frame colour, a subtle border, or a soft coloured glow like Shadow 8 instead.
No more prefixes: the original examples repeated every box-shadow, border-radius and transform line with -webkit-, -moz-, -ms- and -o- versions. All of these properties have worked without prefixes in every browser for many years, so the code above leaves them out.
Wrapping up
With box-shadow, a couple of pseudo-elements and the occasional filter, you can give images anything from a barely-there lift to curled corners and stacked prints. Start with one of the ten above, tweak the numbers to suit your design, and keep your shadows consistent across the page.