HTML | DOM Style textDecorationColor Property

The Style textDecorationColor property in HTML DOM is used to set the color of the text-decoration like underlines, overlines, and line-throughs. It can also return the text-decoration color.

Syntax:

  • It returns the textDecorationColor property.
    object.style.textDecorationColor
  • It is used to set the textDecorationColor property.
    object.style.textDecorationColor = "color|initial|inherit"

Property Values:

  • color: This is used to specify the color of the text decoration.
  • initial: It sets the textDecorationColorproperty to its default value.
  • inherit: This property is inherited from its parent element.

Return Value: It returns a string that represents the text decoration color property.

Example-1:

filter_none

edit
close

play_arrow

link
brightness_4
code

<!DOCTYPE html>
<html>
  
<head>
    <title>DOM Style textDecorationColor Property </title>
    <style>
        #gfg {
            text-decoration: underline;
        }
    </style>
  
</head>
  
<body>
  
    <center>
        <h1 style="color:green;
                   width:40%;"> 
                GeeksForGeeks 
        </h1>
        <h2>DOM Style textDecorationColor Property </h2>
        
        <p id="gfg"
          A Computer science portal for geeks
        </p>
  
        <button type="button" onclick="geeks()">
            Chanege Decoration
        </button>
  
        <script>
            function geeks() {
  
                //  Set underline color.
                document.getElementById(
                  "gfg").style.textDecorationColor = 
                  "magenta";
            }
        </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 textDecorationColor Property </title>
    <style>
        #gfg {
            text-decoration: underline;
        }
    </style>
  
</head>
  
<body>
  
    <center>
        <h1 style="color:green;
                   width:40%;"> 
                GeeksForGeeks 
            </h1>
        
        <h2>DOM StylestextDecorationColor Property </h2>
        <p id="gfg">
          A Computer science portal for geeks
        </p>
  
        <button type="button" onclick="geeks()">
            Chanege Decoration
        </button>
  
        <script>
            function geeks() {
                
                // Set text decoration color.
                document.getElementById(
                  "gfg").style.textDecorationColor = 
                  "green";
            }
        </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 textDecorationColor property are listed below:

  • Google Chrome 57.0
  • Firefox 36.0
  • Opera 44.0
  • Apple Safari 7.1


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.