How to use text-shadow property In CSS

The text-shadow property in CSS adds a shadow effect to text, providing depth and emphasis. It takes parameters for horizontal and vertical offsets, blur radius, and color, allowing designers to create various text-shadow effects for improved visual appeal.

Syntax:

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

Property Values:

text-shadow property accepts a lot of values, some of them are mentioned in the table below.
Property ValueDescription
h-shadowSets the horizontal shadow around the text.
v-shadowSets the vertical shadow around the text.
blur-radiusSets the blur radius around the text shadow.
colorSets the color of the text shadow.
noneDoes not set anything around the text (no shadow).
initialSets the text shadow to its default initial value.
inheritInherits the property values from its parent element.

Return Value:

It returns a font border/shadow around the text.

Font Border Examples

Example 1: This example uses text-shadow property to create shadow to the text.  

html
<!DOCTYPE html>
<html>

<head>
    <title>
        CSS text-shadow property
    </title>

    <style>
        h1 {
            text-shadow: 0 0 3px #FF0000, 0 0 5px #0000FF;
        }
    </style>
</head>

<body>
    <h1>w3wiki</h1>
</body>

</html>

Output: 

Example 2: This example uses text-shadow property to create bordered text.  

html
<!DOCTYPE html>
<html>

<head>
    <title>
        CSS text-shadow property
    </title>

    <!-- Style to use text-shadow property -->
    <style>
        .GFG {
            color: white;
            font-size: 50px;
            text-shadow: -1px 1px 0 #000,
                1px 1px 0 #000,
                1px -1px 0 #000,
                -1px -1px 0 #000;
        }
    </style>
</head>

<body>
    <p class="GFG">w3wiki</p>
</body>

</html>

Output:

CSS Font Border

The CSS Font Border is a technique used to create a border-like outline around HTML text characters. This technique enhances visibility or adds a decorative effect to the text. It can be achieved using the text-stroke property, which allows customization of text appearance by adding a border around it.

Similar Reads

How to Apply Font Border in CSS

There are two methods to apply font borders to text elements in HTML:...

1. Using text-shadow property

The text-shadow property in CSS adds a shadow effect to text, providing depth and emphasis. It takes parameters for horizontal and vertical offsets, blur radius, and color, allowing designers to create various text-shadow effects for improved visual appeal....

2. Using text-stroke property

The text-stroke property is used to add a stroke to the text. This property can change the width and color of the text and is supported by using the -webkit- prefix....

Contact Us