Style borderColor Property

Definition and Usage

borderColor The property sets or returns the color of the element's border.

This property can take one to four values:

  • A value, for example: p {border-color: red} - All four borders are red
  • Two values, for example: p {border-color: red transparent} - The top and bottom borders are red, and the left and right borders are transparent
  • Three values, for example: p {border-color: red green blue} - The top border is red, the left and right borders are green, and the bottom border is blue
  • Four values, for example: p {border-color: red green blue yellow} - The top border is red, the right border is green, the bottom border is blue, and the left border is yellow

See Also:

CSS Tutorial:CSS Border

CSS Reference Manual:border-color Property

HTML DOM Reference Manual:border Property

Example

Example 1

Changes the border color of the <div> element's four borders to red:

document.getElementById("myDiv").style.borderColor = "red";

Try It Yourself

Example 2

Changes the border color of the <div> element's top and bottom borders to green, and the left and right borders to purple:

document.getElementById("myDiv").style.borderColor = "green purple";

Try It Yourself

Example 3

Returns the border color of the <div> element:

alert(document.getElementById("myDiv").style.borderColor);

Try It Yourself

Syntax

Return borderColor Property:

object.style.borderColor

Set borderColor Property:

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

Property Value

Value Description
color

Specifies the color of the border. The default color is black.

See CSS Color Values, for a complete list of possible color values.

transparent The border color is transparent (the underlying content will show through).
initial Sets this property to its default value. See initial.
inherit Inherits this property from its parent element. See inherit.

Technical Details

Default Value: black
Return Value: A string representing the color of the element's border.
CSS Version: CSS1

Browser Support

The numbers in the table indicate the first browser version to fully support this property.

Chrome Edge Firefox Safari Opera
Chrome Edge Firefox Safari Opera
1.0 4.0 1.0 1.0 3.5