CSS border-top-color property

Definition and Usage

The border-top-color sets the color of the top border of the element.

Only pure colors can be defined, and the border may only appear when the border style is not "none" or "hidden".

Note:Always declare the border-style property before the border-color property. The element must have a border before you change its color.

See also:

CSS Tutorial:CSS Borders

CSS Reference Manual:border-top Attribute

HTML DOM Reference Manual:borderTopColor Property

Example

Set the top border color:

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

Try it yourself

CSS Syntax

border-top-color: color|transparent|initial|inherit;

Attribute Value

Attribute Value

Value Description
color_name Specifies the border color as a color name (e.g., red).
hex_number Specifies the border color as a hexadecimal value (e.g., #ff0000).
rgb_number Specifies the border color as an RGB code (e.g., rgb(255,0,0)).
transparent Default Value. The border color is transparent.
inherit Specifies that the border color should be inherited from the parent element.

Technical Details

Default Value: not specified
Inheritance: no
Version: CSS1
JavaScript Syntax: object.style.borderTopColor="blue"

More examples

Set the top border color
This example demonstrates how to set the color of the top border.

Browser support

The numbers in the table indicate the first browser version that fully supports this attribute.

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

Note:Internet Explorer 6 (and earlier versions) do not support the attribute value "transparent".

Note:Browsers prior to IE7 do not support the value "inherit". IE8 requires !DOCTYPE. IE9 supports "inherit".