CSS border-width
Property
Topic: CSS3 Properties ReferencePrev|Next
Description
The border-width
CSS property is a shorthand property for setting the individual border width properties i.e. border-top-width
, border-right-width
, border-bottom-width
, and border-left-width
in a single declaration.
The following table summarizes the usages context and the version history of this property.
Default value: | medium |
---|---|
Applies to: | All elements |
Inherited: | No |
Animatable: | Yes. See animatable properties. |
Version: | CSS 1, 2, 3 |
Syntax
The syntax of the property is given with:
border-width |
[ thin | medium | thick | length ] 1 to 4 values | inherit |
This shorthand notation can take one, two, three, or four whitespace separated values.
- If one value is specified, it applies to all border sides.
- If two values are specified, the first value is used for the top and bottom border, while the second value is used for the right and left border.
- If three values are specified, the first value is used for the top border, the second value is used for the right and left border, and the third value is used for the bottom border.
- If four values are specified, each value applies to the border individually in the order top, right, bottom, and left.
The example below shows the border-width
property in action.
Example
Try this code »p {
border-style: solid;
border-width: 5px;
}
Note: You must declare the border-style
property before the border-bottom-width
property. An element must have borders before you can set the width of the border, because the default value of the border-style
property is none
.
Property Values
The following table describes the values of this property.
Value | Description |
---|---|
thin |
A thin border. |
medium |
A medium border. |
thick |
A thick border. |
length | A length value in px , pt , cm , em , etc. Negative values are not allowed. |
inherit |
If specified, the associated element takes the computed value of its parent element border-width property. |
Browser Compatibility
The border-width
property is supported in all major modern browsers.
Browser Support–
|
Further Reading
See tutorial on: CSS Border, CSS3 Border.
Related properties: border
, border-style
, border-color
, border-top-width
, border-right-width
, border-bottom-width
, border-left-width
.