The CSS text-shadow property adds a shadow to text. It takes a comma-separated list of shadows that apply to the text and its decorations. Each shadow is described by a horizontal offset, a vertical offset, an optional blur radius and an optional color.
/* offset-x offset-y blur-radius color */
text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.3);
Text shadows add emphasis, depth and volume to text. This guide covers how the values work, the patterns you’ll use in real projects, 19 creative effects you can tune live, and the places where another property does the job better.
How text-shadow Works
Each shadow takes two or three lengths and an optional color:
offset-xmoves the shadow right (positive) or left (negative).offset-ymoves it down (positive) or up (negative).blur-radiusis optional and defaults to0, which gives a hard-edged copy of the text. Negative values are invalid.- The color is optional and can come before or after the lengths. Leave it out and the shadow uses the text color.
Separate several shadows with commas to stack them. MDN describes the order this way:
“When more than one shadow is given, shadows are applied front-to-back, with the first-specified shadow on top.”
– MDN Web Docs, text-shadow
The builder below shows that order. Select a layer to edit it, hide or add layers, then switch on the 3D view to pull the stack apart and see which shadow is painted where.
.title {
text-shadow:
2px 2px 0 #ffb42f, /* 1: top */
5px 5px 0 #c0392b, /* 2 */
10px 14px 22px rgba(0, 0, 0, 0.7); /* 3: bottom */
}What text-shadow Doesn’t Do
If you’re used to box-shadow, you’ll notice two things missing: there’s no spread value and no inset keyword. I tested both in current Chrome, Firefox and Safari (WebKit). All three reject them and drop the whole declaration.
Shadows don’t affect layout. A 200px offset won’t push content or add a scrollbar, and the box won’t make room for a big glow. If a parent with overflow: hidden clips the shadow, add padding.
The property inherits. Children pick up the parent’s shadow unless they set their own, so use text-shadow: none wherever you don’t want it.
Support isn’t a concern. MDN marks text-shadow as Baseline Widely available, with support across browsers since July 2015. The unprefixed property works in all current major browsers, so you don’t need -moz- or -webkit- versions.
Common text-shadow Patterns
Before we dive into the creative stuff, here are four text-shadow patterns you’ll reach for again and again in real projects.
1. Subtle Drop Shadow
The most common use. A soft offset shadow that lifts text off the page.
.drop-shadow {
color: #2c2c2c;
text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.2);
}
2. Emboss / Letterpress
A 1px light shadow below text that is slightly darker than its background makes the letters look pressed into the surface, the classic letterpress effect. On a dark surface, a 1px dark shadow above the text gives a similar carved, engraved look. The illusion only works when text color and shadow color are tuned to match the background, so adjust all three together when using this on a different surface.
/* Letterpress: slightly darker text on a light background */
.letterpress {
background: #c8c4bc;
color: #a8a49c;
text-shadow: 0 1px 0 rgba(255, 255, 255, 0.6);
}
/* Engrave: slightly lighter text on a dark background */
.engrave {
background: #3a3a3a;
color: #555;
text-shadow: 0 -1px 0 rgba(0, 0, 0, 0.6),
0 1px 0 rgba(255, 255, 255, 0.12);
}
3. Hard Outline / Stroke
Multiple zero-blur shadows at small offsets in every direction create a solid outline around text – a reliable alternative to -webkit-text-stroke.
.outline {
color: white;
text-shadow:
-2px -2px 0 #1a1a2e,
2px -2px 0 #1a1a2e,
-2px 2px 0 #1a1a2e,
2px 2px 0 #1a1a2e,
0 -2px 0 #1a1a2e,
0 2px 0 #1a1a2e,
-2px 0 0 #1a1a2e,
2px 0 0 #1a1a2e;
}
4. Readable Body Text
A barely-there shadow that adds a hint of depth to body copy on textured or off-white backgrounds. You won’t notice the shadow directly, but remove it and the text feels flatter.
.readable-body {
color: #3a3a3a;
text-shadow: 0 1px 1px rgba(0, 0, 0, 0.08);
}
Interactive text-shadow Playground
Drag the sliders to see how each value changes the effect in real time, switch color presets, or click the word and type your own. The code under each demo updates as you go. Click Copy to grab the complete rule, keyframes included, ready to paste into your project.
/* Put the dark background (#0b0710) on the parent,
so the flicker only fades the word. */
.neon {
color: color-mix(in srgb, #00eaff 25%, white);
font-family: 'Monoton', cursive;
text-shadow:
0 0 4px #fff,
0 0 9.6px #00eaff,
0 0 16px #00eaff,
0 0 48px rgba(0, 234, 255, 0.7),
0 0 96px rgba(0, 234, 255, 0.35);
animation: neon-flicker 5s infinite;
}
@keyframes neon-flicker {
0%, 18%, 22%, 62%, 64%, 100% { opacity: 1; }
20%, 63% { opacity: 0.55; }
}.retro-3d {
background: #fbeedd;
color: #ff5a3c;
font-family: 'Dela Gothic One', sans-serif;
text-shadow:
3px 3px 0 #ffb627,
6px 6px 0 #ff8c42,
9px 9px 0 #e4572e,
12px 12px 0 #a23b72,
15px 15px 0 #3b1f5c;
}.glitch {
background: #050505;
color: #fff;
font-family: 'Space Mono', monospace;
text-shadow:
-5px 0 0 #ff003c,
5px 0 0 #00e5ff;
animation: glitch 0.4s steps(2) infinite;
}
@keyframes glitch {
25% { text-shadow: 5px -2.5px 0 #ff003c, -5px 2.5px 0 #00e5ff; }
50% { text-shadow: 2.5px 5px 0 #ff003c, -2.5px -5px 0 #00e5ff; }
75% { text-shadow: -5px 2.5px 0 #ff003c, 5px -2.5px 0 #00e5ff; }
}.letterpress {
background: #efe9de;
color: rgba(90, 70, 45, 0.5);
font-family: 'Playfair Display', serif;
font-weight: 900;
text-shadow:
0 1px 0 rgba(255, 255, 255, 0.95),
0 -1px 0 rgba(0, 0, 0, 0.3);
}.rainbow {
background: #15152b;
color: #fff;
font-family: 'Righteous', sans-serif;
text-shadow:
4px 4px 0 #e40303,
8px 8px 0 #ff8c00,
12px 12px 0 #ffed00,
16px 16px 0 #00a33c,
20px 20px 0 #0057ff,
24px 24px 0 #8a1fc7;
}.frosted {
background: radial-gradient(circle at 20% 30%, #7f5af0, transparent 45%),
radial-gradient(circle at 80% 70%, #2cb1bc, transparent 45%),
radial-gradient(circle at 60% 15%, #ff6ac1, transparent 40%), #1b1f3b;
color: rgba(255, 255, 255, 0.92);
font-weight: 800;
text-shadow:
0 0 4.5px rgba(255, 255, 255, 0.9),
0 0 18px rgba(201, 184, 255, 0.75),
0 0 39.6px rgba(201, 184, 255, 0.45);
}/* Put the dark background (#0d0705) on the parent,
so the flicker only moves the word. */
.fire {
color: #fff3c4;
font-family: 'Dela Gothic One', sans-serif;
text-shadow:
0 0 3.6px #ffd54f,
0 -5.4px 9px #ff9100,
0 -12.6px 18px #ff3d00,
0 -18px 28.8px rgba(139, 0, 0, 0.8),
0 -36px 54px rgba(90, 90, 90, 0.3),
0 -57.6px 72px rgba(70, 70, 70, 0.15);
animation: fire-flicker 1.6s ease-in-out infinite alternate;
}
/* Brightens and lifts the whole word slightly. */
@keyframes fire-flicker {
50% { filter: brightness(1.12); transform: translateY(-1px); }
}.blueprint {
background-color: #0b3a6e;
background-image:
linear-gradient(rgba(255, 255, 255, 0.12) 1px, transparent 1px),
linear-gradient(90deg, rgba(255, 255, 255, 0.12) 1px, transparent 1px);
background-size: 24px 24px;
/* Text in the background color hides the grid inside the letters;
the shadows draw the outline and a ghost copy */
color: #0b3a6e;
font-family: 'Space Mono', monospace;
text-shadow:
1px 0 0 rgba(255, 255, 255, 0.92),
-1px 0 0 rgba(255, 255, 255, 0.92),
0 1px 0 rgba(255, 255, 255, 0.92),
0 -1px 0 rgba(255, 255, 255, 0.92),
1px 1px 0 rgba(255, 255, 255, 0.92),
-1px -1px 0 rgba(255, 255, 255, 0.92),
1px -1px 0 rgba(255, 255, 255, 0.92),
-1px 1px 0 rgba(255, 255, 255, 0.92),
6px 6px 0 rgba(255, 255, 255, 0.18);
}/* 40 layers, 1px apart, fading out */
.long-shadow {
background: #16a085;
color: #fff;
font-family: 'Dela Gothic One', sans-serif;
text-shadow:
0.7px 0.7px 0 rgba(0, 0, 0, 0.312),
1.4px 1.4px 0 rgba(0, 0, 0, 0.304),
2.1px 2.1px 0 rgba(0, 0, 0, 0.297),
2.8px 2.8px 0 rgba(0, 0, 0, 0.289),
3.5px 3.5px 0 rgba(0, 0, 0, 0.281),
4.2px 4.2px 0 rgba(0, 0, 0, 0.273),
4.9px 4.9px 0 rgba(0, 0, 0, 0.265),
5.7px 5.7px 0 rgba(0, 0, 0, 0.258),
6.4px 6.4px 0 rgba(0, 0, 0, 0.250),
7.1px 7.1px 0 rgba(0, 0, 0, 0.242),
7.8px 7.8px 0 rgba(0, 0, 0, 0.234),
8.5px 8.5px 0 rgba(0, 0, 0, 0.226),
9.2px 9.2px 0 rgba(0, 0, 0, 0.219),
9.9px 9.9px 0 rgba(0, 0, 0, 0.211),
10.6px 10.6px 0 rgba(0, 0, 0, 0.203),
11.3px 11.3px 0 rgba(0, 0, 0, 0.195),
12px 12px 0 rgba(0, 0, 0, 0.187),
12.7px 12.7px 0 rgba(0, 0, 0, 0.180),
13.4px 13.4px 0 rgba(0, 0, 0, 0.172),
14.1px 14.1px 0 rgba(0, 0, 0, 0.164),
14.8px 14.8px 0 rgba(0, 0, 0, 0.156),
15.6px 15.6px 0 rgba(0, 0, 0, 0.148),
16.3px 16.3px 0 rgba(0, 0, 0, 0.140),
17px 17px 0 rgba(0, 0, 0, 0.133),
17.7px 17.7px 0 rgba(0, 0, 0, 0.125),
18.4px 18.4px 0 rgba(0, 0, 0, 0.117),
19.1px 19.1px 0 rgba(0, 0, 0, 0.109),
19.8px 19.8px 0 rgba(0, 0, 0, 0.101),
20.5px 20.5px 0 rgba(0, 0, 0, 0.094),
21.2px 21.2px 0 rgba(0, 0, 0, 0.086),
21.9px 21.9px 0 rgba(0, 0, 0, 0.078),
22.6px 22.6px 0 rgba(0, 0, 0, 0.070),
23.3px 23.3px 0 rgba(0, 0, 0, 0.062),
24px 24px 0 rgba(0, 0, 0, 0.055),
24.7px 24.7px 0 rgba(0, 0, 0, 0.047),
25.5px 25.5px 0 rgba(0, 0, 0, 0.039),
26.2px 26.2px 0 rgba(0, 0, 0, 0.031),
26.9px 26.9px 0 rgba(0, 0, 0, 0.023),
27.6px 27.6px 0 rgba(0, 0, 0, 0.016),
28.3px 28.3px 0 rgba(0, 0, 0, 0.008);
}.cosmic {
background: radial-gradient(ellipse at center, #2a0f4d, #08020f);
color: #f5ecff;
font-family: 'Righteous', sans-serif;
text-shadow:
8px 0 0 #b388ff,
0 8px 0 #ffd740,
-8px 0 0 #1de9b6;
animation: orbit 3s linear infinite;
}
@keyframes orbit {
25% { text-shadow: 0 -8px 0 #b388ff, 8px 0 0 #ffd740, 0 8px 0 #1de9b6; }
50% { text-shadow: -8px 0 0 #b388ff, 0 -8px 0 #ffd740, 8px 0 0 #1de9b6; }
75% { text-shadow: 0 8px 0 #b388ff, -8px 0 0 #ffd740, 0 -8px 0 #1de9b6; }
}.typewriter {
background: #f6f1e3;
color: rgba(28, 27, 26, 0.88);
font-family: 'Special Elite', monospace;
text-shadow:
1px 0 0 rgba(28, 27, 26, 0.5),
0 1px 1px rgba(28, 27, 26, 0.3),
0.5px 0.5px 4px rgba(28, 27, 26, 0.22);
}.chrome {
background: linear-gradient(180deg, #1f242b, #0c0e11);
color: #e4e8ee;
font-family: 'Bebas Neue', sans-serif;
letter-spacing: 0.06em;
text-shadow:
0 -1.5px 0 rgba(255, 255, 255, 0.55),
0 1.5px 0 rgba(0, 0, 0, 0.45),
0 2px 0 rgba(0, 0, 0, 0.35),
0 4px 2px rgba(0, 0, 0, 0.45),
0 10px 12px rgba(0, 0, 0, 0.5);
}.pulse {
background: #0e0a14;
color: color-mix(in srgb, #ff5c9e 35%, white);
font-family: 'Righteous', sans-serif;
text-shadow:
0 0 4.8px #ff5c9e,
0 0 12px #ff5c9e,
0 0 24px rgba(255, 92, 158, 0.5);
animation: pulse 2s ease-in-out infinite;
}
@keyframes pulse {
50% {
text-shadow:
0 0 9.6px #ff5c9e,
0 0 24px #ff5c9e,
0 0 48px rgba(255, 92, 158, 0.6);
}
}.electric {
background: #03040b;
color: #e6f7ff;
font-family: 'Bebas Neue', sans-serif;
letter-spacing: 0.08em;
text-shadow:
1.8px 0 3px #00d4ff,
-1.2px 0.6px 6px #0088ff,
0 0 15px rgba(0, 150, 255, 0.45);
animation: spark 1s steps(3) infinite;
}
@keyframes spark {
33% {
text-shadow:
-2.4px 1.2px 2.4px #00d4ff,
1.8px -1.2px 8.4px #0088ff,
0 0 18px rgba(0, 150, 255, 0.6);
}
66% {
text-shadow:
0.6px -1.8px 1.8px #7df9ff,
-1.8px 0 4.8px #0088ff,
0 0 9px rgba(0, 150, 255, 0.3);
}
}.duotone {
background: #f4f1ea;
color: #16161d;
font-family: 'Playfair Display', serif;
font-weight: 900;
text-shadow:
-5px -5px 0 #e84393,
5px 5px 0 #0984e3;
}More text-shadow Examples
/* The fill is a clipped background, and backgrounds paint
below text-shadow, so the shadow lands on top of the letters. */
.plaster {
background-color: #7d6d5a;
-webkit-background-clip: text;
background-clip: text;
color: transparent;
font-family: 'Bebas Neue', sans-serif;
letter-spacing: 0.2em;
text-shadow: 0 2px 1px rgba(255, 255, 255, 0.45);
}/* Put the dark background (#1a0707) on the parent,
so the filter only changes the word. */
.california {
color: #ffd2c2;
font-family: 'Marck Script', cursive;
text-shadow:
0 0 2.4px #fff,
0 0 8px orangered,
0 0 16px firebrick,
0 0 32px maroon,
0 0 64px darkred;
filter: saturate(60%);
animation: california-flicker steps(100) 3s 3s infinite;
}
@keyframes california-flicker {
50% {
color: white;
filter: saturate(200%) hue-rotate(20deg);
}
}/* 8 hard shadows draw the outline, 3 more the drop, 5 soft ones the depth */
.caricature {
background: linear-gradient(135deg, #ff3e7f, #ff9a3c 55%, #ffd23f);
color: #fff;
font-family: 'Dela Gothic One', sans-serif;
letter-spacing: 0.06em;
text-shadow:
0 -3px 0 #212121,
0 3px 0 #212121,
-3px 0 0 #212121,
3px 0 0 #212121,
-3px -3px 0 #212121,
3px -3px 0 #212121,
-3px 3px 0 #212121,
3px 3px 0 #212121,
-3px 9px 0 #212121,
0 9px 0 #212121,
3px 9px 0 #212121,
0 18.9px 1px rgba(0, 0, 0, 0.1),
0 11.7px 4px rgba(0, 0, 0, 0.2),
0 9px 9px rgba(0, 0, 0, 0.25),
0 24.3px 24.3px rgba(0, 0, 0, 0.2),
0 36px 36px rgba(0, 0, 0, 0.15);
}.moving-shadow {
background: #24243a;
color: #ffd54f;
font-family: 'Dela Gothic One', sans-serif;
text-shadow:
1px 1px 2px rgba(0, 0, 0, 0.7),
5px 5px 1px #ff6b00,
6px 6px 2px rgba(0, 0, 0, 0.7),
10px 10px 1px #e84040,
11px 11px 2px rgba(0, 0, 0, 0.7),
15px 15px 1px #9b59b6,
16px 16px 2px rgba(0, 0, 0, 0.7);
animation: snake 1s infinite alternate ease-in-out;
}
@keyframes snake {
to {
text-shadow:
-1px 1px 2px rgba(0, 0, 0, 0.7),
-5px 5px 1px #ff6b00,
-6px 6px 2px rgba(0, 0, 0, 0.7),
-10px 10px 1px #e84040,
-11px 11px 2px rgba(0, 0, 0, 0.7),
-15px 15px 1px #9b59b6,
-16px 16px 2px rgba(0, 0, 0, 0.7);
}
}text-shadow in Real UI
The effects above are fun, but most uses of text-shadow in production are quieter. These eight patterns come up in real interfaces. Each card has a Shadow toggle so you can see what changes, except the last one, where you select the text instead.
Headlines Over Busy Photos
A soft dark shadow helps white text stand apart from a busy photo. One shadow is rarely enough here, so stack a tight one around the letter edges and a wide one for the halo.
.hero-title {
color: #fff;
text-shadow:
0 1px 2px rgba(0, 0, 0, 0.6), /* crisp edge */
0 4px 24px rgba(0, 0, 0, 0.55); /* soft halo */
}
.hero-subtitle {
text-shadow: 0 1px 3px rgba(0, 0, 0, 0.85);
}
If the text still fights the photo, add a gradient overlay behind it. A shadow helps the edges, but a faint one can’t separate light text from the brightest parts of a photo.
Glowing Links and Buttons
A glow on hover and keyboard focus is a classic use. Browsers interpolate each shadow’s offsets, blur and color, so a transition on text-shadow runs smoothly. Try hovering over the links below (the middle one already shows its hover state). For more ideas, see these creative button hover effects.
.nav a {
color: #c9ced8;
transition: color 0.25s ease, text-shadow 0.25s ease;
}
.nav a:hover,
.nav a:focus-visible {
color: #fff;
text-shadow:
0 0 8px rgba(255, 180, 47, 0.75),
0 0 22px rgba(255, 180, 47, 0.45);
}
.nav-cta:hover,
.nav-cta:focus-visible {
color: #fff3d6;
text-shadow: 0 0 10px rgba(255, 180, 47, 0.9);
}
Shadows on Gradient Text
Gradient text uses background-clip: text with a transparent color (more on that in the background-clip guide). Add a text-shadow and it paints over the gradient, because backgrounds are drawn below the shadow. Use filter: drop-shadow() instead. It shadows the finished letters, gradient and all.
.gradient-title {
background: linear-gradient(90deg, #ff3cac, #784ba0, #2b86c5);
-webkit-background-clip: text;
background-clip: text;
color: transparent;
/* text-shadow would paint on top of the gradient */
filter: drop-shadow(0 4px 6px rgba(0, 0, 0, 0.3));
}
Sale Badges and Stickers
Stickers are a fun use of stacked hard shadows. Eight white shadows around the letters cut out a die-cut edge. Eight dark ones, each shifted by the same offset, give that whole shape a solid drop, and a final blurred shadow lifts it off the page.
.sticker {
transform: rotate(-8deg);
color: #ff3c6f;
font-family: 'Dela Gothic One', sans-serif;
text-shadow:
/* white die-cut edge: 8 directions, 5px out */
5px 0 0 #fff, -5px 0 0 #fff, 0 5px 0 #fff, 0 -5px 0 #fff,
3.5px 3.5px 0 #fff, -3.5px 3.5px 0 #fff,
3.5px -3.5px 0 #fff, -3.5px -3.5px 0 #fff,
/* the same 8 offsets, shifted 6px 7px, in dark */
11px 7px 0 #16161d, 1px 7px 0 #16161d,
6px 12px 0 #16161d, 6px 2px 0 #16161d,
9.5px 10.5px 0 #16161d, 2.5px 10.5px 0 #16161d,
9.5px 3.5px 0 #16161d, 2.5px 3.5px 0 #16161d,
/* soft lift */
6px 22px 26px rgba(122, 62, 0, 0.35);
}
Big Numbers on Dashboards
A soft glow in the number’s own color makes key metrics stand out on a dark dashboard. color-mix() builds the glow from the same variable, so one color change updates both.
.kpi strong {
color: var(--k);
text-shadow: 0 0 18px color-mix(in srgb, var(--k) 45%, transparent);
}
Light and Dark Themes
A shadow that looks right on a light page usually looks muddy on a dark one. Use a soft dark shadow on light backgrounds and switch to a faint glow on dark backgrounds.
h1 {
text-shadow: 0 2px 6px rgba(31, 36, 48, 0.18);
}
@media (prefers-color-scheme: dark) {
h1 {
text-shadow: 0 0 14px rgba(255, 180, 47, 0.35);
}
}
Hebrew and Other RTL Text
Shadow offsets are physical, not logical. A positive offset-x moves the shadow to the right even in a right-to-left heading. If you want the shadow to fall in the reading direction, flip the sign for RTL pages.
.title {
text-shadow: 4px 4px 0 #b8113e; /* right and down, in LTR and RTL alike */
}
.title:dir(rtl) {
text-shadow: -4px 4px 0 #b8113e; /* left and down: toward the end of an RTL line */
}
Styling Selected Text
::selection accepts text-shadow, though few sites use that combination. Select the paragraph below to see the highlighted words glow.
Highlight this sentence with your mouse or finger. The selection gets a dark background and a soft gold glow around each letter.
Select the text abovep::selection {
background: #1d2433;
color: #fff;
text-shadow: 0 0 8px rgba(255, 180, 47, 0.9);
}
text-shadow vs. drop-shadow() vs. box-shadow
Three properties can put a shadow near your text. A fourth draws an outline. Here’s what each one does to the same word:
The first two look the same here, but they work differently:
| Property | What gets the shadow | Several shadows | Best for |
|---|---|---|---|
text-shadow |
Each letter and its decorations | Yes, comma list | Glows, depth, outlines, retro effects |
filter: drop-shadow() |
Everything the element paints, including its background | Chain functions (each one also shadows the previous result) | Gradient text, text with icons |
box-shadow |
The element’s box, not the letters | Yes, with spread and inset | Cards, buttons, panels |
-webkit-text-stroke |
Draws an outline, not a shadow | No | Thin, even outlines |
Give an element a solid background and drop-shadow() shadows the whole box, while text-shadow still follows the letters. The stroke property only works with its -webkit- prefix, but that prefixed form works in Chrome, Firefox and Safari.
Accessibility and Performance
Don’t count on a shadow to fix contrast. Most contrast checkers compare the text color with the background color and ignore the shadow. Pick colors that pass on their own, then add the shadow.
Each time an animated shadow changes, the browser repaints the text, which for a smooth animation means every frame. A few small ones are fine. For a large glowing hero, put the glow on a pseudo-element and animate its opacity instead. Browsers can usually hand that work to the GPU.
Respect motion settings. Flicker, glitch and pulse effects should stop for people who ask for less motion, as the demos on this page do:
@media (prefers-reduced-motion: reduce) {
.neon,
.glitch,
.fire,
.cosmic,
.pulse,
.electric,
.california,
.moving-shadow {
animation: none;
}
}
FAQs
Common questions about CSS text-shadow:
Summary
text-shadow takes two offsets, an optional blur and an optional color. You can stack as many shadows as you like. The first one in the list sits on top.
Keep shadows subtle when they help people read text over photos, spot focus states or pick out dashboard numbers. Save the stacked, animated effects for headlines. For gradient text, use drop-shadow() instead.
Which effect did you like most? If you build a shadow worth sharing, post it in the comments.
