CSS text-shadow Property

Beginner
5 min read
Updated: Oct 2026
3 examples
Live preview

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 color

If you omit the shadow color, the browser picks a default. Set an explicit color for consistent results across browsers.

CSS Syntax

syntax.css
text-shadow: none | h-offset v-offset blur? color? | initial | inherit;

Color may appear before or after the offsets. Separate multiple shadows with commas.

Property Values

ValueDescriptionTry it
noneDefault. No shadowTry it
h-offset v-offsetRequired lengths. Negative moves left / upTry it
blur-radiusOptional. Larger values soften and widen the shadow (default 0)Try it
colorOptional shadow color (set it explicitly)Try it
MultipleComma-separated list; first shadow paints on topTry it
initialResets to noneTry it
inheritTakes the parent’s shadowTry it

How to Use text-shadow

Start with offsets and a color, then add blur or extra layers if you need soft glow.

  1. Pick horizontal and vertical offsets (for example 2px 2px).
  2. Add a blur length if you want a soft edge (for example 4px).
  3. Set a clear color (hex, named, or rgba()).
  4. Stack more shadows with commas for glow or depth.
PieceRequired?Role
Offset X / YYes (when not none)Where the shadow sits relative to the glyphs
Blur radiusNoSoftens the shadow; defaults to 0
ColorRecommendedShadow paint color
Extra shadowsNoComma-separated layers for richer effects

Live Preview

Switch presets to compare no shadow, a hard offset, a soft blur, a glow, and layered shadows.

Offsets move the shadow; blur softens it; commas stack layers.

Shadow preview

CodeToFun

text-shadow: 2px 2px 6px rgba(15, 23, 42, 0.45)

CSS Examples

Each snippet focuses on text-shadow only. Use Try It Yourself for a live editor.

Example 1 — Basic Offset Shadow

Two offsets and a color—no blur.

CSS
<style>
  p {
    text-shadow: 2px 2px #64748b;
  }
</style>

<p>CodeToFun</p>
Try It Yourself

How It Works

  1. Move right. First length 2px is the X offset.
  2. Move down. Second length 2px is the Y offset.
  3. Paint gray. #64748b sets the shadow color.
  4. Hard edge. No blur value means a sharp shadow.

Example 2 — Soft Blur

Add a blur radius for a softer, lighter shadow.

CSS
<style>
  p {
    text-shadow: 2px 2px 6px rgba(15, 23, 42, 0.45);
  }
</style>

<p>CodeToFun</p>
Try It Yourself

How It Works

  1. Keep offsets. 2px 2px still places the shadow.
  2. Add blur. 6px spreads the shadow edge.
  3. Use rgba. Partial opacity keeps the effect subtle.
  4. Common UI look. Soft shadows read cleaner than hard ones.

Example 3 — Multiple Shadows

Comma-separated layers build glow and depth.

CSS
<style>
  p {
    color: white;
    text-shadow:
      1px 1px 2px black,
      0 0 0.6em blue,
      0 0 0.2em blue;
  }
</style>

<p>CodeToFun</p>
Try It Yourself

How It Works

  1. List shadows. Separate each layer with a comma.
  2. Top layer first. 1px 1px 2px black paints nearest.
  3. Glow layers. 0 0 … keeps glow centered on the glyphs.
  4. 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.

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.

97% Modern browsers
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.

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

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.
The initial value is none—no shadow.
Yes. Child text inherits the parent shadow unless it sets its own value.
Yes. List them comma-separated. They paint front to back, with the first shadow on top.
text-shadow follows the glyph shapes. box-shadow follows the element’s box (rectangle or rounded border box).
It is Baseline Widely available (interoperable since about July 2015). It is a browser layout/paint property, not a Node.js feature.

Next: text-transform

Learn how to change the case of text with CSS.

text-transform tutorial →

About the author

Mari Selvan M P
Mari Selvan M P 🔗

Developer, cloud engineer, and technical writer

  • Experience 12 years building web and cloud systems
  • Focus Full Stack Development, AWS, and Developer Education

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