🌟 CSS text-shadow
— Add Depth, Glow, and Drama to Text
The text-shadow
property lets you apply one or more shadows to text. Whether you’re aiming for subtle depth, a neon glow, or dramatic typography, this property is flexible, powerful, and widely supported.
🔹 What Does text-shadow
Do?
It adds shadow effects to text, similar to drop shadows in graphic design. You can control:
- The horizontal offset
- The vertical offset
- The blur radius
- The shadow color
📘 Syntax
selector {
text-shadow: h-offset v-offset blur color;
}
You can also apply multiple shadows separated by commas.
💡 Example Values
Property Part | What It Does | Example |
---|---|---|
h-offset | Moves shadow left/right (+ = right) | 2px |
v-offset | Moves shadow up/down (+ = down) | 2px |
blur-radius | Blurs the shadow (optional) | 4px |
color | Sets the shadow color | rgba(0,0,0,0.5) |
✍️ Basic Example: Simple Drop Shadow
<h2 class="drop-shadow">Elegant Title</h2>
.drop-shadow {
text-shadow: 2px 2px 5px rgba(0, 0, 0, 0.4);
}
✅ A soft shadow appears to the bottom-right of the text with a slight blur.
✨ Advanced Example: Neon Glow Effect
.neon-text {
color: #0ff;
text-shadow:
0 0 5px #0ff,
0 0 10px #0ff,
0 0 20px #0ff,
0 0 40px #0ff;
}
🎉 The result is bright, glowing text, perfect for retro or sci-fi designs.
🖼️ Image Idea: Visual Examples of text-shadow
Image Description:
Four versions of the same word:
- ✅ No shadow (default)
- ☁️ Subtle drop shadow
- 💡 Glow (multiple blur layers)
- 🖍️ Dramatic offset (hard shadow)
🎯 Purpose: Show how different shadow settings change the mood and clarity.
🎨 Multiple Shadows Example
.multishadow {
text-shadow:
2px 2px 2px red,
-2px -2px 2px blue;
}
✅ Creates a layered 3D-like effect with red and blue shadows on opposite sides.
🧠 Best Use Cases
Use Case | Suggested Shadow Style |
---|---|
Headings | Soft blur for readability |
Buttons | Slight shadow for emphasis |
Dark backgrounds | Light glow for contrast |
Games, sci-fi, neon UI | Multi-glow or high-contrast colored shadows |
Creative typography | Layered or offset shadows |
🧠 Tips for Clean Design
- Use light shadows for subtle elegance.
- Avoid overdoing multiple shadows unless for effect.
- Combine with
font-weight
andletter-spacing
for better balance. - Use RGBA or HSLA for better opacity control.
✅ Summary
Property | text-shadow |
---|---|
What it affects | Inline text (not background or box) |
Parameters | Horizontal offset, vertical offset, blur, color |
Multiple shadows | Yes, using comma separation |
Good for | Emphasis, glow effects, legibility, depth |
🔚 Final Thought
The text-shadow
property is a designer’s secret weapon — giving your text clarity, emphasis, or wow factor with just a few lines of code. From elegant to electric, the possibilities are endless.