Skip to content
Related Articles

Related Articles

HTML | DOM Style borderTop Property

View Discussion
Improve Article
Save Article
  • Last Updated : 16 Jun, 2022

The DOM style borderTop property is used to set or returns the three different border-top property such as border-top-width, border-top-style, and border-top-color of an element.
Syntax: 
 

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

Property value: 
 

  • width: This will set the width of top border.
  • style: This will set the style of top border.
  • color: This will set the color of top border.
  • initial: This will set the property to it’s default value.
  • inherit: This will inherit the property from it’s parent element

Return Value: It returns a string value which represents the width, style and/or color of the top border of an element.
Example 1: 
 

html




<!DOCTYPE html>
<html>
    <head>
        <title>DOM Style borderTop Property</title>
    </head>
     
    <body>
        <center>
            <h1 style = "color:green;width:50%;" id = "sudo">
                GeeksForGeeks
            </h1>
             
            <h2>DOM Style borderTop Property </h2>        
            <br>
            <button type = "button" onclick = "geeks()">
                Submit
            </button>
             
            <script>
            function geeks() {
            document.getElementById("sudo").style.borderTop
                                        = "thick solid green";
            }
            </script>
        </center>
    </body>
</html>                    

Output: 
Before Click on the button: 
 

After Click on the button: 
 

Example 2: 
 

html




<!DOCTYPE html>
<html>
    <head>
        <title>DOM Style borderTop Property</title>
    </head>
    <body>
        <center>
            <h1 style = "color:green;">
                GeeksForGeeks
            </h1>
             
            <h2>DOM Style borderTop Property </h2>
             
            <h3 style = "border:2px solid red;width:50%;"
                id = "sudo">geksforgeeks</h3>
            <br>
            <button type = "button" onclick = "geeks()">
                Submit
            </button>
             
            <script>
                function geeks() {
                    document.getElementById("sudo").style.borderTop
                                            = "thick dotted green";
                }
            </script>
        </center>
    </body>
</html>                    

Output: 
Before Click on the button: 
 

After Click on the button: 
 

Supported Browsers: The browser supported by DOM style borderTop property are listed below: 
 

  • Google Chrome 1 and above
  • Edge 12 and above
  • Internet Explorer 4 and above
  • Firefox 1 and above
  • Opera 3.5 and above
  • Apple Safari 1 and above

 


My Personal Notes arrow_drop_up
Recommended Articles
Page :

Start Your Coding Journey Now!