CSS Text Shadow

The CSS text-shadow property allows you to add shadow effects to text, enhancing the visual appearance. It helps in making text stand out by adding depth and style. You can specify the shadow's horizontal and vertical offsets, blur radius, and color.

Key Points on CSS Text Shadow:

Syntax for CSS Text Shadow:

Syntax Example

/* Syntax for text-shadow */
        text-shadow: horizontal-offset vertical-offset blur-radius color;
                
        /* Example */
        text-shadow: 2px 2px 5px rgba(0, 0, 0, 0.5);

Examples of CSS Text Shadow:

The following examples demonstrate the usage of text-shadow property:

Code Example: Basic Text Shadow

h1 {
            text-shadow: 2px 2px 3px #000;
        }

Output

This heading has a simple text shadow.

Code Example: Multiple Text Shadows

h2 {
            text-shadow: 2px 2px 3px rgba(0, 0, 0, 0.3), 4px 4px 6px rgba(0, 0, 0, 0.2);
        }

Output

This heading has multiple text shadows.

Code Example: Glowing Text Shadow

p {
            text-shadow: 0 0 10px #ff0000, 0 0 20px #ff0000;
        }

Output

This paragraph has a glowing text shadow effect.

Common Properties of CSS Text Shadow:

To make the text-shadow effect more appealing, consider using subtle shadows for text readability or combining different colors for creative designs. Avoid using too many layers of shadows as it can clutter the design.