border-color
property sets the color for the
whole border or sets a different color for each of the four sides.
We can individually change the color of the bottom, left, top and right sides of an element's border using the following CSS properties:
Item | Value |
---|---|
Inherited | No. |
Version | CSS1 |
JavaScript syntax | object.style.borderColor="#FF0011 red" |
Applies to | All elements. |
border-color: color [ color color color]
The following code shows the rules for default border color value.
border-color:red green blue pink;
is equal to
border-color:red green blue;
is equal to
border-color:red green;
is equal to
border-color:red;
is equal to
The property values are listed in the following table.
Value | Description |
---|---|
color | Set the color. Default color is black. |
transparent | Set border color to transparent. Default value |
inherit | Inherit the border color from the parent element |
border-color |
Yes | Yes | Yes | Yes | Yes |
An example showing how to use border-color CSS property.
<!DOCTYPE HTML>
<html>
<head>
<style>
div{ text-align: center;<!-- w ww. j a va 2s.c o m-->
margin-bottom: 1em;
padding: .5em;
border-width: thick;
border-color: blue;
border-style: groove;
}
</style>
</head>
<body>
<div>this is a test. </div>
</body>
</html>