CSS PROPERTIES
Expand All|Collapse All
CSS AT-RULES
SPONSORED LINKS

CSS border-color Property

Topic: CSS3 Properties Reference« Prev|Next »

Description

The border-color CSS property is a shorthand property for setting the individual border color properties i.e. border-top-color, border-right-color, border-bottom-color, and border-left-color in a single declaration.

The following table summarizes the usages context and the version history of this property.

Default value: See individual properties
Applies to: All elements
Inherited: No
Animatable: Yes. See animatable properties.
Version: CSS 1, 2, 3

Syntax

The syntax of the property is given with:

border-color [ color | transparent ] 1 to 4 values | inherit

This shorthand notation can take one, two, three, or four whitespace separated values.

  • If one value is specified, it applies to all border sides.
  • If two values are specified, the first value is used for the top and bottom border, while the second value is used for the right and left sides border.
  • If three values are specified, the first value is used for the top border, the second value is used for the right and left border, and the third value is used for the bottom border
  • If four values are specified, each value applies to the border individually in the order top, right, bottom, and left.

The example below shows the border-color property in action.

  • p {
  •     border-style: solid;
  •     border-color: #ff0000;
  • }
 

Note:You must declare the border-style property before the border-color property. An element must have borders before you can set the color of the border, because the default value of border-style property is none.


Property Values

The following table describes the values of this property.

Value Description
color Specifies the color of the border. Look at CSS Color Values for the list of possible color values.
transparent Allows the border to be transparent, though it may occupy the space set by the border-width property.
initial Sets this property to its default value.
inherit If specified, the associated element takes the computed value of its parent element border-color property.

Browser Compatibility

The border-color property is supported in all major modern browsers.

Browsers Icon

Basic Support—

  • Firefox 1+
  • Google Chrome 1+
  • Internet Explorer 4+
  • Apple Safari 1+
  • Opera 4+

Further Reading

See tutorial on: CSS Border, CSS3 Border.

Related properties: border, border-style, border-width, border-top-color, border-right-color, border-bottom-color, border-left-color.

 
Close

Your Feedback:

 

We would love to hear from you! Please say something.