The border-top
property is a shorthand property used to specify the width, style and color of the top border of an element.
It is a shorthand property for the longhand properties: border-top-width
, border-top-style
and border-top-color
properties of an element.
The border-top
property can accept one, two or three arguments as a value—omitted values are set to their initial values.
Official Syntax
-
Syntax:
border-top: <line-width> || <line-style> || <color>
-
Initial:
0 none currentColor
, which is the concatenation of the initial values of the long-hand properties. - Applies To: all elements
- Animatable: The width and color of the border are animatable.
Values
- <line-width>
-
The width of the top border. Refer to the
border-top-width
property entry for a list of possible values. - <line-style>
-
The style of the top border. Refer to the
border-top-style
property entry for a list of possible values. - <color>
-
The color of the top border. Refer to the
border-top-color
property entry for a list of possible values.
Examples
The following are all valid border-top
values set on an element.
.element { border-top: 1em; /* style and color are set to their initial values */ /* or */ border-top: dotted deepPink; /* width is set to its initial value (0), which means that no top border will be set */ /* or */ border-top: 1px dotted #eee; /* or */ border-top: 10px solid #009966; }
Browser Support
The property works in all major browsers: Chrome, Firefox, Safari, Opera, IE, and on Android and iOS.