Home CSS Properties text-shadow CSS text-shadow Property Definition
Definition and Usage The text-shadow property adds one or more shadows to text and its text-decoration . Each shadow is built from X/Y offsets, an optional blur radius, and an optional color.
It is inherited. The initial value is none. Shadows also apply to ::first-line and ::first-letter.
Note Always set a colorIf you omit the shadow color, the browser picks a default. Set an explicit color for consistent results across browsers.
Syntax
CSS Syntax text-shadow: none | h-offset v-offset blur? color? | initial | inherit ;
Color may appear before or after the offsets. Separate multiple shadows with commas.
Values
Property Values Value Description Try it noneDefault. No shadow Try ith-offset v-offsetRequired lengths. Negative moves left / up Try itblur-radiusOptional. Larger values soften and widen the shadow (default 0) Try itcolorOptional shadow color (set it explicitly) Try itMultiple Comma-separated list; first shadow paints on top Try itinitialResets to none Try itinheritTakes the parent’s shadow Try it
Approach
How to Use text-shadow Start with offsets and a color, then add blur or extra layers if you need soft glow.
Pick horizontal and vertical offsets (for example 2px 2px). Add a blur length if you want a soft edge (for example 4px). Set a clear color (hex, named, or rgba()). Stack more shadows with commas for glow or depth. Piece Required? Role Offset X / Y Yes (when not none) Where the shadow sits relative to the glyphs Blur radius No Softens the shadow; defaults to 0 Color Recommended Shadow paint color Extra shadows No Comma-separated layers for richer effects
Try it
Live Preview Switch presets to compare no shadow, a hard offset, a soft blur, a glow, and layered shadows.
Code
CSS Examples Each snippet focuses on text-shadow only. Use Try It Yourself for a live editor.
1. Basic 2. Soft blur 3. Multiple Example 1 — Basic Offset Shadow Two offsets and a color—no blur.
<style>
p {
text-shadow: 2px 2px #64748b;
}
</style>
<p>CodeToFun</p> Blur defaults to 0 when omitted.
How It Works Move right. First length 2px is the X offset.Move down. Second length 2px is the Y offset.Paint gray. #64748b sets the shadow color.Hard edge. No blur value means a sharp shadow.Example 2 — Soft Blur Add a blur radius for a softer, lighter shadow.
<style>
p {
text-shadow: 2px 2px 6px rgba(15, 23, 42, 0.45);
}
</style>
<p>CodeToFun</p> Larger blur widens and softens the shadow.
How It Works Keep offsets. 2px 2px still places the shadow.Add blur. 6px spreads the shadow edge.Use rgba. Partial opacity keeps the effect subtle.Common UI look. Soft shadows read cleaner than hard ones.Example 3 — Multiple Shadows Comma-separated layers build glow and depth.
<style>
p {
color: white;
text-shadow:
1px 1px 2px black,
0 0 0.6em blue,
0 0 0.2em blue;
}
</style>
<p>CodeToFun</p> First shadow in the list sits on top.
How It Works List shadows. Separate each layer with a comma.Top layer first. 1px 1px 2px black paints nearest.Glow layers. 0 0 … keeps glow centered on the glyphs.Contrast. Light text on a dark stage shows the glow clearly. Edge Cases & Pitfalls Small details that change how shadows look or perform.
color Omit color → UA default Browsers may disagree on the default shadow color. Always set one.
vs box Not the same as box-shadow box-shadow follows the box. text-shadow follows the letter shapes.
a11y Keep contrast readable Heavy glow or dark shadows on busy backgrounds can hurt legibility. Prefer subtle values for body text.
perf Many large blurs cost more Several wide blur layers can be expensive to paint. Keep UI shadows light.
decor Decorations get the shadow too Underlines and other text decorations share the same text-shadow.
Compatibility
Browser Support text-shadow is a browser painting property . Node.js, Deno, and Bun do not apply it.
✓ Baseline · Widely available
text-shadow Interoperable across modern browsers since about July 2015. Safe for everyday typography effects.
Google Chrome 2+
Full
Mozilla Firefox 3.5+
Full
Apple Safari 1.1+
Full
Microsoft Edge 12+
Full
Opera 9.5+
Full
Samsung Internet 1+
Full
Internet Explorer 10+
Full text-shadow Widely supported
Bottom line: Production-ready. Prefer explicit colors and modest blur for consistent, readable results.
Remember
Key Takeaways Role: paint shadows that follow text glyphs (and decorations).
Parts: X/Y offsets required; blur and color optional (set color anyway).
Layers: comma-separated list; first shadow is on top. Inherited.
Tip: use soft blur for UI; save multi-glow for headings on dark backgrounds.
One line: text-shadow is offset + optional blur + color, stackable with commas.
Frequently Asked Questions What does the CSS text-shadow property do? It draws one or more shadows behind text (and its text-decoration). Each shadow uses X/Y offsets, an optional blur radius, and an optional color.
What is the default value of text-shadow? The initial value is none—no shadow.
Is text-shadow inherited? Yes. Child text inherits the parent shadow unless it sets its own value.
Can I use multiple shadows? Yes. List them comma-separated. They paint front to back, with the first shadow on top.
How is text-shadow different from box-shadow? text-shadow follows the glyph shapes. box-shadow follows the element’s box (rectangle or rounded border box).
Which browsers support text-shadow? It is Baseline Widely available (interoperable since about July 2015). It is a browser layout/paint property, not a Node.js feature.
About the author Developer, cloud engineer, and technical writer
I write practical tutorials so students and working developers can learn by doing—from databases and APIs to deployment on AWS.
8 people found this page helpful
Helpful Share Copy link Suggestion