Open In App

HTML | DOM Style textShadow Property

The style textShadow property in HTML DOM is used to set the shadow effects for text. We can set more than one shadow effects by using this property. This property can also return the shadow effects of a text. 

Syntax:



object.style.textShadow
object.style.textShadow = "none|h-shadow v-shadow blur color|
initial|inherit"

Property Values:

Return Value:



Example 1: 




<!DOCTYPE html>
<html>
<head>
    <title>DOM Style textShadow Property </title>
    <style>
    </style>
</head>
<body>
    <center>
        <h1 style="color:green;width:40%;">
                GeeksForGeeks
            </h1>
        <h2>DOM Style textShadow Property </h2>
        <p id="gfg">
          A Computer science portal for geeks
      </p>
        <button type="button" onclick="geeks()">
            Change Style
        </button>
        <script>
            function geeks() {
               
                //  Set textShadow in green color.
                document.getElementById(
                  "gfg").style.textShadow =
                  "5px 5px 1px green";
            }
        </script>
    </center>
</body>
</html>

Output:

Example 2: 




<!DOCTYPE html>
<html>
<head>
    <title>DOM Style textShadow Property </title>
    <style>
    </style>
</head>
<body>
    <center>
        <h1 style="color:green;width:40%;">
           GeeksForGeeks
        </h1>
        <h2>DOM Style textShadow Property </h2>
        <p id="gfg">
          A Computer science portal for geeks
        </p>
        <button type="button" onclick="geeks()">
            Shadow effect
        </button>
        <script>
            function geeks() {
               
                //  Set textShadow in magenta color.
                document.getElementById(
                  "gfg").style.textShadow =
                  "-3px -5px 1px magenta";
            }
        </script>
    </center>
</body>
</html>

Output:

Supported Browsers: The browser supported by DOM Style textShadow property are listed below:


Article Tags :