CSS border
Property
Topic: CSS3 Properties ReferencePrev|Next
Description
The border
property sets the width, style, and color for all four sides of an element's border. It is a shorthand property for setting the individual border properties i.e. border-width
, border-style
, and border-color
in a single declaration.
The following table summarizes the usages context and the version history of this property.
Default value: | See individual properties |
---|---|
Applies to: | All elements |
Inherited: | No |
Animatable: | Yes, See individual properties. See animatable properties. |
Version: | CSS 1, 2, 3 |
Syntax
The syntax of the property is given with:
Note: If any property listed above is missing or omitted, the default value for that property will be inserted, if any. See individual properties for details.
The example below shows the border
property in action.
Example
Try this code »h1 {
border: 5px solid #ff0000;
}
p {
color: #00ff00;
border: 5px solid;
}
Note: If border-color
is missing or not specified (e.g. border: 5px solid;
) the value of the element's color
property will be used instead. But, in the case of border-style
, skipping or omitting the value will cause no border to show at all, because the default value for border-style
property is none
.
Property Values
The following table describes the values of this property.
Value | Description |
---|---|
border-width |
Sets the width of the border of an element. |
border-style |
Sets the line style of the border of an element. |
border-color |
Sets the color of the border of an element. |
initial |
Sets this property to its default value. |
inherit |
If specified, the associated element takes the computed value of its parent element border property. |
Browser Compatibility
The border
property is supported in all major modern browsers.
Basic Support—
|
Further Reading
See tutorial on: CSS Border, CSS3 Border.
Related properties: border-width
, border-style
, border-color
, border-collapse
, border-image
, border-radius
, border-spacing
.