Style borderColor property
The Style object
Definition and Usage
The borderColor property sets or returns the color of an element's border.
This property can use from 1 to 4 colors:
- If one color is specified, for example: p {border-color: red} - all four borders are red.
- If two colors are specified, for example: p {border-color: red transparent} - the top and bottom borders are red, while the left and right borders are transparent.
- If three colors are specified, 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.
- If four colors are specified, 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.
Syntax
Set the borderColor property:
Object.style.borderColor="
color
|transparent|inherit"
Return the borderColor property:
Object.style.borderColor
| Value | Description |
|---|---|
| color | Specifies the color of the border. In A CSS color value the CSS color reference you can find a complete list of possible color values. |
| transparent | Default. The color of the border is transparent (underlying content will show through). |
| inherit | The color of the border is inherited from the parent element. |
Browser support





All major browsers support the borderColor property.
**Note:** IE7 and earlier versions do not support the "inherit" value. IE8 supports "inherit" only if a !DOCTYPE is specified. IE9 supports "inherit".
Example
Example
Change the color of the four borders:
This is some text.
Try it »
The Style object