Open In App

HTML | DOM Style borderTopColor Property

The borderTopColor property allows us to set/get the color of top border of element. 

Syntax: 



object.style.borderTopColor
object.style.borderTopColor = "color|transparent|initial|
inherit"

Return Value:The borderTopColor property returns the color of the top border of an element. 

Property Values: 



1. color:It specifies the top border color of corresponding element. Black is default color. 

Syntax: 

borderTopColor = "red"

Example: 




<!DOCTYPE html>
<html>
<head>
    <title>
        HTML | DOM Style borderTopColor Property
    </title>
    <style>
        #GFG_Div {
            width: 200px;
            margin-left: 210px;
            border: thick solid green;
        }
    </style>
</head>
 
<body align="center">
     
<p>
     Click to change the right border
     color of element.
    </p>
 
 
    <button type="button" onclick="myGeeks()">
     Click to change
    </button>
    <br>
    <br>
    <div id="GFG_Div">GeeksforGeeks</div>
    <script>
        function myGeeks() {
            document.getElementById("GFG_Div")
                .style.borderTopColor = "red";
        }
    </script>
 
</body>
 
</html>

Output: 

Syntax:

borderTopColor = "yellow"

Example: 




<!DOCTYPE html>
<html>
<head>
    <title>
        HTML | DOM Style borderTopColor Property
    </title>
    <style>
        #GFG_Div {
            width: 200px;
            margin-left: 210px;
            border: thick solid green;
        }
    </style>
</head>
 
<body align="center">
     
<p>
     Click to change the top border
     color of element.
    </p>
 
 
    <button type="button" onclick="myGeeks()">
     Click to change
    </button>
    <br>
    <br>
    <div id="GFG_Div">GeeksforGeeks</div>
    <script>
        function myGeeks() {
            document.getElementById("GFG_Div")
                .style.borderTopColor = "yellow";
        }
    </script>
 
</body>
 
</html>

Output: 

2. transparent:It sets the top border color of corresponding element to transparent. 

Syntax: 

borderTopColor = "transparent"

Example: 




<!DOCTYPE html>
<html>
 
<head>
    <title>
        HTML | DOM Style borderTopColor Property
    </title>
    <style>
        #GFG_Div {
            width: 200px;
            margin-left: 210px;
            border: thick solid green;
        }
    </style>
</head>
 
<body align="center">
     
<p>
      Click to change the right border
      color of element.</p>
 
 
    <button type="button" onclick="myGeeks()">
      Click to change
    </button>
    <br>
    <br>
    <div id="GFG_Div">GeeksforGeeks</div>
    <script>
        function myGeeks() {
            document.getElementById("GFG_Div")
                .style.borderTopColor = "transparent";
        }
    </script>
 
</body>
 
</html>

Output: 

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


Article Tags :