border-top
Specifies top border properties all at once. The properties you can set together are 'border-color', 'border-style', and 'border-width'. The order of values does not matter.
Sample Code
div.test { border-top: dashed;}
div.test1 { border-top: dashed 2px;}
div.test2 { border-top: solid 2px #000;}
Available Values (border-color)
| Value | Description |
|---|---|
| transparent | Sets the border color to transparent. |
| Color code or color name | Changes the border to the specified color. If no 'border-color' value is specified, the 'color' property value is used as the initial value. |
Available Values (border-style)
| Value | Description |
|---|---|
| none | No border is drawn. The width also becomes 0. This is the initial value. |
| solid | Draws a single solid line. |
| dashed | Draws a dashed border with larger gaps. |
| dotted | Draws a dotted border with smaller gaps. |
| double | Draws a border with two lines. |
| groove | Draws a border that looks carved in. Opposite of 'ridge'. |
| ridge | Draws a border that looks raised. Opposite of 'groove'. |
| inset | Draws a border that looks embedded. Opposite of 'outset'. |
| outset | Draws a border that looks raised outward. Opposite of 'inset'. |
Available Values (border-width)
| Value | Description |
|---|---|
| Number | Specifies the border width in units such as 'px'. |
| thin | The keyword 'thin'. Typically rendered as 1px, though it may vary slightly by browser. |
| medium | The keyword 'medium'. Typically rendered as 3px, though it may vary slightly by browser. This is the initial value when no 'border-width' is specified. |
| thick | The keyword 'thick'. Typically rendered as 5px, though it may vary slightly by browser. |
Browser Preview
<div style="border-top: none; height: 100px; padding: 10px; font-weight: bold;">A div element with height 100px and padding 10px.</div>
<div style="border-top: solid 10px #cccccc; height: 100px; padding: 10px; font-weight: bold;">A div element with height 100px and padding 10px.</div>
<div style="border-top: dashed 10px #cccccc; height: 100px; padding: 10px; font-weight: bold;">A div element with height 100px and padding 10px.</div>
<div style="border-top: dotted 10px #cccccc; height: 100px; padding: 10px; font-weight: bold;">A div element with height 100px and padding 10px.</div>
<div style="border-top: double 10px #cccccc; height: 100px; padding: 10px; font-weight: bold;">A div element with height 100px and padding 10px.</div>
<div style="border-top: groove 10px #cccccc; height: 100px; padding: 10px; font-weight: bold;">A div element with height 100px and padding 10px.</div>
<div style="border-top: ridge 10px #cccccc; height: 100px; padding: 10px; font-weight: bold;">A div element with height 100px and padding 10px.</div>
<div style="border-top: inset 10px #cccccc; height: 100px; padding: 10px; font-weight: bold;">A div element with height 100px and padding 10px.</div>
<div style="border-top: outset 10px #cccccc; height: 100px; padding: 10px; font-weight: bold;">A div element with height 100px and padding 10px.</div>
Browser Support
8 ○
7 ○
6 ○
2 and earlier ×
Android Browser
4.4+ ○
3 and earlier ×※ Version data based on MDN.
Overview
Sets the 'border-color', 'border-style', and 'border-width' properties for the top border all at once. The order of values does not matter.
When 'border-top' is specified, any top border properties not explicitly set are reset to their initial values. In other words, all previously specified top border properties are overridden.
<div style="border-width: 10px; border-style: dashed; border-top: solid; height: 100px; padding: 10px; font-weight: bold;">A div element with height 100px and padding 10px.</div>
To display a top border, you must always specify a 'border-style' value. The initial value of 'border-style' is 'none' (width 0), so no border will be drawn unless a value is explicitly set.
If you find any errors or copyright issues, please contact us.