Add shadow effects to text with CSS

The text-shadow property in CSS is used to add shadow effects to text, creating depth and visual appeal. This property helps make text stand out and gives it a three-dimensional appearance on web pages.

Syntax

text-shadow: h-shadow v-shadow blur-radius color;

Property Values

Value Description
h-shadow Horizontal offset of the shadow (required)
v-shadow Vertical offset of the shadow (required)
blur-radius Blur distance (optional, default is 0)
color Shadow color (optional, uses text color if not specified)

Example 1: Basic Text Shadow

The following example shows a simple shadow with horizontal and vertical offset −

<!DOCTYPE html>
<html>
<head>
<style>
    body {
        font-family: Arial, sans-serif;
        text-align: center;
        background-color: #f0f0f0;
        padding: 50px;
    }
    .shadow-text {
        font-size: 48px;
        color: #333;
        text-shadow: 4px 4px;
    }
</style>
</head>
<body>
    <h1 class="shadow-text">TUTORIALSPOINT</h1>
</body>
</html>
Large text "TUTORIALSPOINT" appears with a dark gray shadow offset 4px to the right and 4px down.

Example 2: Colored Text Shadow

This example demonstrates adding a colored shadow to text −

<!DOCTYPE html>
<html>
<head>
<style>
    body {
        font-family: Arial, sans-serif;
        text-align: center;
        background-color: #e8f5e8;
        padding: 50px;
    }
    .colored-shadow {
        font-size: 48px;
        color: #2c3e50;
        text-shadow: 4px 4px tomato;
    }
</style>
</head>
<body>
    <h1 class="colored-shadow">TUTORIALSPOINT</h1>
</body>
</html>
Dark blue text "TUTORIALSPOINT" with a bright tomato-colored shadow offset to the bottom-right.

Example 3: Blurred Text Shadow

The following example adds a blur effect to the shadow for a softer appearance −

<!DOCTYPE html>
<html>
<head>
<style>
    body {
        font-family: Arial, sans-serif;
        text-align: center;
        background-color: #fff9e6;
        padding: 50px;
    }
    .blurred-shadow {
        font-size: 48px;
        color: white;
        text-shadow: 6px 6px 10px #333;
    }
</style>
</head>
<body>
    <h1 class="blurred-shadow">TUTORIALSPOINT</h1>
</body>
</html>
White text "TUTORIALSPOINT" with a soft, blurred dark shadow creating a floating effect.

Example 4: Multiple Text Shadows

You can apply multiple shadows by separating them with commas −

<!DOCTYPE html>
<html>
<head>
<style>
    body {
        font-family: Arial, sans-serif;
        text-align: center;
        background-color: #1a1a1a;
        padding: 50px;
    }
    .multi-shadow {
        font-size: 48px;
        color: #fff;
        text-shadow: 2px 2px 0px red, 
                     4px 4px 0px blue, 
                     6px 6px 0px green;
    }
</style>
</head>
<body>
    <h1 class="multi-shadow">TUTORIALSPOINT</h1>
</body>
</html>
White text with layered colored shadows creating a 3D rainbow effect with red, blue, and green shadows stacked.

Conclusion

The text-shadow property is a powerful tool for enhancing text appearance. You can create simple shadows with just offset values or complex effects using blur radius, colors, and multiple shadows.

Updated on: 2026-03-15T12:04:25+05:30

292 Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements