CSS border-top-color Property
More "Try it Yourself" examples below.
Definition and Usage
The border-top-color
property sets the color of an element's top border.
Note: Always declare the border-style or the
border-top-style property before the border-top-color
property. An element must have a border before you can change the color.
Default value: | The current color of the element |
---|---|
Inherited: | no |
Animatable: | yes. Read about animatable Try it |
Version: | CSS1 |
JavaScript syntax: | object.style.borderTopColor="blue" Try it |
Browser Support
The numbers in the table specify the first browser version that fully supports the property.
Property | |||||
---|---|---|---|---|---|
border-top-color | 1.0 | 4.0 | 1.0 | 1.0 | 3.5 |
CSS Syntax
border-top-color: color|transparent|initial|inherit;
Property Values
Value | Description | Demo |
---|---|---|
color | Specifies the color of the top border. Look at CSS Color Values for a complete list of possible color values. Default color is the current color of the element | Demo ❯ |
transparent | Specifies that the border color should be transparent | Demo ❯ |
initial | Sets this property to its default value. Read about initial | |
inherit | Inherits this property from its parent element. Read about inherit |
More Examples
Example
Set a color for the top border with a HEX value:
div {border-top-color: #92a8d1;}
Try it Yourself »
Example
Set a color for the top border with an RGB value:
div {border-top-color: rgb(201, 76, 76);}
Try it Yourself »
Example
Set a color for the top border with an RGBA value:
div {border-top-color: rgba(201, 76, 76, 0.3);}
Try it Yourself »
Example
Set a color for the top border with a HSL value:
div {border-top-color: hsl(89, 43%, 51%);}
Try it Yourself »
Example
Set a color for the top border with a HSLA value:
div {border-top-color: hsla(89, 43%, 51%, 0.3);}
Try it Yourself »
Related Pages
CSS tutorial: CSS Border
CSS reference: border-top property
HTML DOM reference: borderTopColor property