- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
Physics
Chemistry
Biology
Mathematics
English
Economics
Psychology
Social Studies
Fashion Studies
Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
HTML DOM Style borderColor Property
The borderColor property is used for setting or getting the border color of an element. Using the borderColor property we can manipulate the colors on each side of the border i.e. each side border having different color.
Syntax
Following is the syntax for −
Setting the borderColor property
object.style.borderColor = "color|transparent|initial|inherit"
Values
The property values are explained as follows −
Sr.No | Values & Description |
---|---|
1 | Color For specifying the border color. |
2 | Transparent This makes the border color transparent and the content under it can be seen. |
3 | initial For setting this property to initial value. |
4 | inherit To inherit the parent property value |
Example
Let us look at an example for the borderColor Property −
<!DOCTYPE html> <html> <head> <style> #DIV1{ width:100px; height:100px; border:solid 10px ; border-color: limegreen crimson; top: 10px; } </style> <script> function changeBorderColor(){ document.getElementById("DIV1").style.borderColor="crimson limegreen"; document.getElementById("Sample").innerHTML="The border colors are now reversed "; } </script> </head> <body> <div id="DIV1"></div> <p>Reverse the above div border colors by clicking the below button</p> <button onclick="changeBorderColor()">Change Border Color</button> <p id="Sample"></p> </body> </html>
Output
This will produce the following output −
On clicking the COLLAPSE BORDER button −
Advertisements