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.
Fundamentals
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.
Foundation
📝 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.
A highlight shadow below-right and a darker shadow above-left trick the eye into seeing depth on a flat surface.
A11y
♿ 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.
Companion
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.
Compatibility
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 Chrome4+ · Desktop & Mobile
Full support
Mozilla Firefox3.5+ · Desktop & Mobile
Full support
Apple Safari4+ · macOS & iOS
Full support
Microsoft Edge12+ · All versions
Full support
Opera9.5+ · All versions
Full support
Testing tip
Legacy IE did not support text-shadow. For current projects, no vendor prefixes are required.
text-shadow property99% supported
Bottom line:text-shadow is safe to use for decorative typography in all modern web projects.
Wrap Up
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.
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
Summary
Key Takeaways
Knowledge Unlocked
Five things to remember about text-shadow
Use these points when styling typography with shadows.
5
Core concepts
🎨01
Text depth
Shadows behind glyphs.
Purpose
∅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).