English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية

CSS Reference Manual

CSS @rules (RULES)

Comprehensive CSS Properties

CSS border-top-color attribute usage and example

border-top-color CSS attribute is used to set the color of the upper border of the element separately. However, in many cases, like   border-colororborder-topSuch shorthand CSS properties are more convenient and preferable to use.

The following table provides usage instructions and version history of this attribute, as well as its syntax in JavaScript scripts.

Default value:colorAttribute value
Applies to:All elements
Inheritance:No
Animated:Yes.Please refer to Animation properties.
Version:CSS 1,2,3
JavaScript syntax:object.style.borderTopColor="red"

border-top-color usage syntax

The syntax of this attribute is as follows:

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

The following examples demonstrate how to use border-top-color attribute.

  p {
   border-style: solid;
   border-top-color: #ff0000;
  }
Test and see‹/›

Note:You must specify in border-bottom-width attribute is declared beforeborder-styleAttribute. The element must have a border before it can set the border width, because theborder-styleThe default value of the attribute is none.

Attribute value

The following table describes the value of this attribute.

ValueDescription
colorSpecify the color of the top border. SeeCSS color valuesto get the list of possible color values.
transparentAllow the border to be transparent, although it may take upborder-widthThe space of the attribute setting.
initialSet this attribute to its default value.
inheritIf specified, the associated element uses its parent element's border-top-The value of color attribute.

Browser compatibility

border-top-The compatibility of color attribute across browsers; the numbers in the table below represent the minimum version number of browsers that support this attribute; all mainstream browsers support this attribute.

  • Firefox 1+

  • Google Chrome1+

  • Internet Explorer 4+

  • Apple Safari 1+

  • Opera 4+

Read more

See tutorial:CSS Border,CSS3 Border.

Related properties:border,border-color,border-top,border-top-style,
border-top-width.