CSS border-color Property

Set a CSS border-color:

div {border-color: coral;}

Try it Yourself »

More “Try it Yourself” examples below.


Definition and Usage

The border-color property sets the color of an element’s four borders. This property can have from one to four values.

If the border-color property has four values:

  • border-color: red green blue pink;
    • top border is red
    • right border is green
    • bottom border is blue
    • left border is pink

If the border-color property has three values:

  • border-color: red green blue;
    • top border is red
    • right and left borders are green
    • bottom border is blue

If the border-color property has two values:

  • border-color: red green;
    • top and bottom borders are red
    • right and left borders are green

If the border-color property has two values:

  • border-color: red;
    • all four borders are red

Note: Always declare the border-style property before the border-color property. An element must have borders before you can change the color.

Default value: The current color of the element
Inherited: no
Animatable: yes. Read about animatable – Try it
Version: CSS1
JavaScript syntax: object.style.borderColor=”#FF0000 blue” Try it
cSS Syntax
border-color: color|transparent|initial|inherit;
Property Values
Value Description Play it
color Specifies the background color. Look at CSS Color Values for a complete list of possible color values. Default color is black div {
border-style:solid;
border-width:5px;
border-color:#c15d26;
}
transparent Specifies that the border color should be transparent div {
border-style:solid;
border-width:5px;
border-color:transparent;
}
initial Sets this property to its default value. Read about initial div {
border-style:solid;
border-width:5px;
border-color:initial;
}
inherit Inherits this property from its parent element. Read about inherit

Set a color for the border with a HEX value:

div {border-color: #92a8d1;}

Try it Yourself »

Example

Set a different border-color for each side of an element:

div.ex1 {border-color: #0000ff;}
div.ex2 {border-color: #ff0000 #0000ff;}
div.ex3 {border-color: #ff0000 #00ff00 #0000ff;}
div.ex4 {border-color: #ff0000 #00ff00 #0000ff rgb(250,0,255);}

Try it Yourself »