CSS text-shadow Property

Beginner
⏱️ 5 min read
📚 Updated: Jun 2026
🎯 4 Examples
Typography

What You’ll Learn

The text-shadow property adds shadow effects to text — from subtle depth to glowing headlines and layered typography styles.

01

Shadow Basics

Offset & blur.

02

Color

RGBA & hex.

03

Multiple

Layer shadows.

04

Glow

Zero offset.

05

Depth

3D effects.

06

Readability

Contrast tips.

Introduction

The text-shadow property in CSS is used to apply shadow effects to text. It allows you to add one or more shadows to text, making it stand out and giving it a three-dimensional effect.

This property can enhance the visual appeal of your text content and is widely used in web design for creating various text effects.

Definition and Usage

Use text-shadow when you want headings, buttons, or hero text to feel more polished — for example, a soft drop shadow on a title over a photo, or a neon glow on dark backgrounds.

💡
Beginner Tip

Start with a simple shadow like text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.3); — two pixels right, two pixels down, a little blur, and a semi-transparent black.

📝 Syntax

The syntax for the text-shadow property is straightforward. It allows you to define multiple shadows, each specified by an offset, a blur radius, and a color.

syntax.css
element {
  text-shadow: offset-x offset-y blur-radius color;
}

Basic Example

text-shadow.css
h1 {
  text-shadow: 2px 2px 5px rgba(0, 0, 0, 0.3);
}

Syntax Rules

  • offset-x — horizontal distance (positive moves right, negative moves left).
  • offset-y — vertical distance (positive moves down, negative moves up).
  • blur-radius — optional; larger values create softer shadows. Defaults to 0 (sharp).
  • color — optional; defaults to the current text color if omitted.
  • Separate multiple shadows with commas; the first shadow is painted on top.

Related Properties

  • box-shadow — adds shadows to an element’s box, not its text shape
  • filter: drop-shadow() — applies a shadow filter to the rendered element
  • color — sets the text color that shadows can complement

🎯 Default Value

The default value of the text-shadow property is none, meaning no shadow is applied to the text.

⚡ Quick Reference

QuestionAnswer
Default valuenone
Basic drop shadowtext-shadow: 2px 2px 4px rgba(0, 0, 0, 0.3);
Glow effecttext-shadow: 0 0 10px #38bdf8;
Multiple shadowstext-shadow: 1px 1px 0 #000, 2px 2px 0 #333;
Remove shadowtext-shadow: none;
InheritedYes

💎 Property Values

Each shadow is built from length and color components. You can also use the keyword none.

ValueExampleDescription
offset-x2px, 0.5emA length value representing the horizontal offset of the shadow.
offset-y2px, -1pxA length value representing the vertical offset of the shadow.
blur-radius5px, 0Optional blur radius. Defaults to 0 for a sharp shadow edge.
color#000, rgba(0,0,0,0.5)Optional color of the shadow. Defaults to the current text color.
nonetext-shadow: none;Removes any shadow from the text.
offset-x offset-y blur-radius color

When to Use text-shadow

text-shadow is a great choice when typography needs extra depth or contrast:

  • Hero headings — Make large titles pop over photos or gradients.
  • Dark UI themes — Add neon or soft glow effects to accent text.
  • Readability — A subtle shadow can help light text stay readable on busy backgrounds.
  • Decorative branding — Layer multiple shadows for retro or 3D letter styles.

👀 Live Preview

Compare a basic drop shadow, a glow, and an embossed style on the same dark panel:

Drop shadow

Text with Shadow

Glow

Neon Glow

Emboss

Raised Text

Examples Gallery

In this example, we’ll apply a simple shadow effect to a heading.

📜 Basic Effects

Start with a single shadow, then explore glow and layered styles.

Example 1 — Simple shadow on a heading

In this example, we’ll apply a simple shadow effect to a heading.

index.html
<style>
  h1 {
    text-shadow: 2px 2px 5px rgba(0, 0, 0, 0.3);
  }
</style>

<h1>Text with Shadow</h1>
Try It Yourself

How It Works

The shadow sits 2px right and 2px down with a 5px blur, using semi-transparent black for a soft depth effect.

Example 2 — Glow with zero offset

When offset is 0 0, the blur creates a halo around each letter — perfect for neon-style headings.

glow.css
.neon {
  color: #e0f2fe;
  text-shadow:
    0 0 8px #38bdf8,
    0 0 16px #0ea5e9;
}
Try It Yourself

How It Works

Two blurred shadows with no offset stack together to create a brighter center and a wider outer glow.

📄 Layered Styles

Combine multiple shadows for retro stacks and embossed lettering.

Example 3 — Multiple stacked shadows

Comma-separated shadows build a bold, layered look often used in posters and game UI.

stacked.css
.stacked {
  color: #fef08a;
  text-shadow:
    1px 1px 0 #ca8a04,
    2px 2px 0 #a16207,
    3px 3px 0 #854d0e;
}
Try It Yourself

How It Works

Each shadow is offset one pixel further down-right with no blur, creating a solid 3D stack behind the letters.

Example 4 — Embossed text

Light and dark shadows on opposite corners simulate raised or pressed lettering.

emboss.css
.emboss {
  color: #cbd5e1;
  text-shadow:
    1px 1px 0 #fff,
    -1px -1px 0 #64748b;
}
Try It Yourself

How It Works

A highlight shadow below-right and a darker shadow above-left trick the eye into seeing depth on a flat surface.

♿ Accessibility

  • Do not rely on shadow alone — Ensure text color contrast meets WCAG guidelines without the shadow.
  • Keep body text subtle — Heavy shadows on paragraphs reduce readability; reserve strong effects for headings.
  • Test on photos — Shadows that help on one background may fail on another; verify real content.
  • Motion sensitivity — Animated glowing text can distract; use animation sparingly.

text-shadow vs box-shadow

text-shadow follows the outline of each character. box-shadow wraps the element’s box. Use text-shadow for typography effects and box-shadow for cards and buttons.

compare.css
/* Shadow follows letter shapes */
h1 { text-shadow: 2px 2px 4px rgba(0,0,0,0.4); }

/* Shadow wraps the element box */
.card { box-shadow: 0 4px 12px rgba(0,0,0,0.15); }

🧠 How text-shadow Works

1

Define offsets

Set how far the shadow moves horizontally and vertically from the text.

Position
2

Add blur (optional)

A blur radius softens the shadow edge. Use 0 for crisp outlines.

Softness
3

Pick a color

Semi-transparent blacks are common; colored glows use bright hues with blur.

Color
=

Text with depth

The browser paints the shadow behind each glyph without extra HTML.

Browser Compatibility

The text-shadow property is supported in all modern browsers, including the latest versions of Chrome, Firefox, Safari, Edge, and Opera. It is also supported in most mobile browsers. However, it is always a good practice to test your website across different browsers to ensure compatibility.

Universal · All modern browsers

Reliable typography effects

Chrome, Firefox, Safari, Edge, and Opera all support text-shadow in current versions without prefixes.

99% Browser support
Google Chrome 4+ · Desktop & Mobile
Full support
Mozilla Firefox 3.5+ · Desktop & Mobile
Full support
Apple Safari 4+ · macOS & iOS
Full support
Microsoft Edge 12+ · All versions
Full support
Opera 9.5+ · All versions
Full support

Testing tip

Legacy IE did not support text-shadow. For current projects, no vendor prefixes are required.

text-shadow property 99% supported

Bottom line: text-shadow is safe to use for decorative typography in all modern web projects.

Conclusion

The text-shadow property is a versatile tool for adding visual depth and interest to text on your web pages.

Whether you’re looking to create subtle shadow effects or dramatic text styles, this property provides the flexibility you need. Experiment with different values to see how text-shadow can enhance your text and make your web designs more engaging.

💡 Best Practices

✅ Do

  • Use subtle shadows on body text for readability over images
  • Start with low blur and semi-transparent colors
  • Layer multiple shadows for intentional design effects
  • Test contrast with and without the shadow enabled
  • Use text-shadow: none; to reset inherited shadows on nested elements

❌ Don’t

  • Apply heavy glow to long paragraphs
  • Depend on shadow alone for essential contrast
  • Stack so many shadows that text becomes illegible
  • Confuse text-shadow with box-shadow on the same element

Key Takeaways

Knowledge Unlocked

Five things to remember about text-shadow

Use these points when styling typography with shadows.

5
Core concepts
02

none

Default value.

Default
03

offset-x/y

Move the shadow.

Position
04

blur

Soft or sharp.

Effect
🔗 05

Multiple

Comma-separated.

Layers

❓ Frequently Asked Questions

text-shadow adds one or more shadow effects behind text. Each shadow is defined by horizontal offset, vertical offset, optional blur radius, and optional color.
The default is none, meaning no shadow is applied to the text.
Yes. Separate multiple shadow definitions with commas. They are painted in order, with the first shadow on top.
Yes, text-shadow is inherited. Setting it on a parent element affects text inside unless a child overrides it.
text-shadow follows the shape of the text glyphs. box-shadow applies to the element's border box as a rectangle (or rounded shape).

Practice in the Live Editor

Open the HTML editor and experiment with offset, blur, and color on a heading.

HTML Editor →

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.

5 people found this page helpful