Open In App

HTML DOM Style borderColor Property

The DOM Style borderColor property specifies the color of the element’s border. It may be given explicitly, inherit from the parent or by default it will take the default value.

Syntax:  



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

Return value: It returns a string value that represents the color of the border.

Property Values  



Syntax: 

borderColor: "red";

Example: In this example, we will change the border color.




<!DOCTYPE html>
<html>
   
<head>
    <style>
        #GFG_Div {
            width: 200px;
            font-size: 20px;
            margin-top: 20px;
            border: thick solid red;
        }
    </style>
</head>
   
<body>
    <button onclick="GFG_Function()">
        Change border color
    </button>
    <div id="GFG_Div">GeeksforGeeks</div>
    <br>
   
    <script>
        function GFG_Function() {
            document.getElementById("GFG_Div")
                .style.borderColor = "green";
        }
    </script>
</body>
   
</html>

Output:

 

Example: In this example, we will change the border color.




<!DOCTYPE html>
<html>
 
<head>
    <style>
        #GFG_Div {
            width: 200px;
            font-size: 20px;
            margin-top: 20px;
            border: thick solid red;
        }
    </style>
</head>
 
<body>
    <button onclick="GFG_Function()">
        Change border color
    </button>
    <div id="GFG_Div">GeeksforGeeks</div>
    <br>
   
    <script>
        function GFG_Function() {
            document.getElementById("GFG_Div")
                .style.borderColor = "red green";
        }
    </script>
</body>
 
</html>

Output: 

 

Example: In this example, we will change the border color.




<!DOCTYPE html>
<html>
   
<head>
    <style>
        #GFG_Div {
            width: 200px;
            font-size: 20px;
            margin-top: 20px;
            border: thick solid red;
        }
    </style>
</head>
   
<body>
    <button onclick="GFG_Function()">
        Change border color
    </button>
    <div id="GFG_Div">GeeksforGeeks</div>
    <br>
   
    <script>
        function GFG_Function() {
            document.getElementById("GFG_Div")
                .style.borderColor = "red green blue";
        }
    </script>
</body>
   
</html>

Output: 

 

Example: In this example, we will change the border color.




<!DOCTYPE html>
<html>
   
<head>
    <style>
        #GFG_Div {
            width: 200px;
            font-size: 20px;
            margin-top: 20px;
            border: thick solid red;
        }
    </style>
</head>
   
<body>
    <button onclick="GFG_Function()">
        Change border color
    </button>
    <div id="GFG_Div">GeeksforGeeks</div>
    <br>
   
    <script>
        function GFG_Function() {
            document.getElementById("GFG_Div")
                .style.borderColor = "red green blue orange";
        }
    </script>
</body>
   
</html>

Output: 

 

Example: Here you will see the use of transparent It sets the border color of the corresponding element to transparent.




<!DOCTYPE html>
<html>
   
<head>
    <style>
        #GFG_Div {
            width: 200px;
            font-size: 20px;
            margin-top: 20px;
            border: thick solid red;
        }
    </style>
</head>
   
<body>
    <button onclick="GFG_Function()">
        Transparent border color
    </button>
    <div id="GFG_Div">GeeksforGeeks</div>
    <br>
   
    <script>
        function GFG_Function() {
            document.getElementById("GFG_Div")
                .style.borderColor = "transparent";
        }
    </script>
</body>
   
</html>

Output: 

 

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


Article Tags :