Open In App

HTML | DOM Style textDecorationLine Property

The Style textDecorationLine property in HTML DOM used to set the decoration for a line. We can specify any number of decorations for a line. It returns the decoration that is given to the text.

Syntax: 



object.style.textDecorationLine
object.style.textDecorationLine = "none|underline|overline|
line-through|initial|inherit"

Property Values: 

Return Value: It returns a string representing the text-decoration-line property for an element.



Example 1: 




<!DOCTYPE html>
<html>
<head>
    <title>DOM Style textDecorationLine Property </title>
    <style>
        #gfg {
            text-decoration: underline;
        }
    </style>
</head>
<body>
    <center>
        <h1 style="color:green;">
                GeeksForGeeks
        </h1>
        <h2>DOM StylestextDecorationLine Property </h2>
        <p id="gfg"> A Computer science portal for geeks</p>
 
        <button type="button" onclick="geeks()">
            Change Decoration
        </button>
        <script>
            function geeks() {
               
                //  Set overline.
                document.getElementById("gfg"
                 ).style.textDecorationLine = "overline";
            }
        </script>
    </center>
</body>
</html>

Output: 

Example 2:  




<!DOCTYPE html>
<html>
<head>
    <title>DOM Style textDecorationLine Property </title>
    <style>
        #gfg {
            text-decoration: underline;
        }
    </style>
</head>
<body>
    <center>
        <h1 style="color:green;">
                GeeksForGeeks
        </h1>
        <h2>DOM StylestextDecorationLine Property </h2>
        <p id="gfg"> A Computer science portal for geeks</p>
 
        <button type="button" onclick="geeks()">
            Change Decoration
        </button>
        <script>
            function geeks() {
               
                //  Set overline-through.
                document.getElementById("gfg"
                 ).style.textDecorationLine =
                  "overline line-through";
            }
        </script>
    </center>
</body>
</html>

Output: 

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


Article Tags :