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:

  • It returns the textShadow property.
    object.style.textShadow
  • It used to set the textShadow property.
    object.style.textShadow = "none|h-shadow v-shadow blur color|
    initial|inherit"

Property Values:

  • none: This property makes no shadow is drawn.This is a default value.
  • h-shadow: This is used to position the horizontal shadow and it allows negative values. This is a mandatory field
  • v-shadow: This is used to position the vertical shadow and it allows negative values. This is a mandatory field.
  • blur: It is an optional one and it specifies the blur distance.
  • color: It is an optional one and is used to specify the color for a shadow.
  • initial: It sets the textShadow property to its default value.
  • inherit: This property is inherited from its parent element.

Return Value:

  • It returns string that represents a comma separated list of shadow effects of textShadow property of a element.

Example-1:

filter_none

edit
close

play_arrow

link
brightness_4
code

<!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>

chevron_right


Output:

  • Before Click on the button:
  • After Click on the button:
  • Example-2:

    filter_none

    edit
    close

    play_arrow

    link
    brightness_4
    code

    <!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>

    chevron_right

    
    

    Output:

    • Before Click on the button:
    • After Click on the button:

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

    • Google Chrome
    • Internet Explorer 10.0
    • Firefox
    • Opera
    • Safari


    My Personal Notes arrow_drop_up


    If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.

    Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.



    Improved By : shubham_singh



    Article Tags :
    Practice Tags :


    Be the First to upvote.


    Please write to us at contribute@geeksforgeeks.org to report any issue with the above content.