π Introduction
The text-shadow property in CSS adds shadow effects to text, allowing you to create depth, glow, highlights, neon effects, embossed looks, and more. It works similarly to box-shadow but applies only to text characters. A powerful tool for modern UI and creative typography! π¨β¨
π― What Does text-shadow Do?
- Adds shadow behind text
- Supports blur, color, offsets
- Allows multiple layered shadows
- Used for neon, 3D text, glow, outline effects
β¨ Syntax
Syntax
text-shadow: <offset-x> <offset-y> <blur-radius> <color>;Note
π§© Value Breakdown
1. offset-x (required)
Horizontal shadow position β positive = right, negative = left.
2. offset-y (required)
Vertical shadow position β positive = down, negative = up.
3. blur-radius (optional)
Controls the softness of the shadow. Higher values produce smoother shadows.
4. color (optional)
Can use HEX, RGB, RGBA, HSL, etc. Use RGBA for transparency.
π₯ Basic Examples
1. Simple Text Shadow
Simple
.simple {
text-shadow: 2px 2px 2px rgba(0,0,0,0.3);
}2. Sharp Text Shadow
Sharp Shadow
.sharp {
text-shadow: 3px 3px 0px black;
}3. Soft Glow Effect
Glow Effect
.glow {
text-shadow: 0 0 10px rgba(0, 150, 255, 0.8);
}4. Multiple Shadows (Layered)
Multiple Shadows
.multi {
text-shadow:
0 1px 2px rgba(0,0,0,0.2),
0 2px 5px rgba(0,0,0,0.15);
}π₯ Advanced Creative Examples
1. Neon Text Effect
Neon Text
.neon {
color: #fff;
text-shadow:
0 0 5px #0ff,
0 0 10px #0ff,
0 0 20px #0ff,
0 0 40px cyan;
}2. 3D Text Effect
3D Effect
.threeD {
text-shadow:
2px 2px 0 #999,
4px 4px 0 #666,
6px 6px 0 #333;
}3. Embossed / Debossed Effect
Embossed
.embossed {
color: #333;
text-shadow:
1px 1px 0 #fff,
-1px -1px 0 #aaa;
}4. Outline Text Using Shadows
Outline Text
.outline {
color: transparent;
text-shadow:
1px 1px 0 #000,
-1px 1px 0 #000,
1px -1px 0 #000,
-1px -1px 0 #000;
}5. Retro Pixel Shadow
Pixel Shadow
.pixel {
text-shadow: 4px 4px 0 #000;
}π Example Comparison Table
| Style | Shadow Example |
|---|---|
| Glow | 0 0 10px rgba(0,150,255,0.8) |
| 3D | Multiple offset shadows |
| Outline | Shadows in 4 directions |
| Inset-like | 1px -1px 0 #aaa, -1px 1px 0 #fff |
π§ Tips for Better Text Shadows
- Use RGBA for soft, realistic shadows
- Use multiple shadows for complex effects
- Avoid large blur on small text (hurts readability)
- For neon effects β use multiple glow layers
- For outline text β stack shadows around all 4 corners
π Conclusion
The text-shadow property is a powerful tool for creating beautiful text effectsβfrom glowing neon signs to 3D lettering and elegant soft shadows. Mastering offsets, blur levels, and multiple shadow layers will help you produce professional, attention-grabbing typography in your UI designs. π