CSS border property
Example
Set the styles of the four borders:
p
{
border:
5
px
solid
red
;
}
Try it »
Tag Definition and Usage Notes
border is a shorthand property for the border properties.
The CSS border property is used to specify the style, width, and color of an element's border.
The properties that can be set are (in order): border-width, border-style, and border-color.
You can also set only one value, for example border: #FF0000; is valid, and the other values are set to the initial values of their respective properties.
Syntax format
You can specify the border property using one, two, or three values listed below, and the order of the values does not matter:
/* border style */
border
:
solid
;
/* border width | border style */
border
:
2px
dotted
;
/* border style | border color */
border
:
outset
#f33
;
/* border width | border style | border color */
border
:
medium
dashed
green
;
/* global values */
border
:
inherit
;
border
:
initial
;
border
:
unset
;
**Note:** If the border style is not defined, it will be invisible. This is because the style defaults to none.
| Default value: | not specified |
|---|---|
| Inherited: | no |
| Version: | CSS1 |
| JavaScript syntax: | object object.style.border="3px solid blue" |
Browser support
The numbers in the table indicate the first browser version that supports this property.
| property | |||||
|---|---|---|---|---|---|
| border | 1.0 | 4.0 | 1.0 | 1.0 | 3.5 |
Attribute values
| Value | Description |
|---|---|
| border-width | Specifies the border width |
| border-style | Specifies the border style |
| border-color | Specifies the border color |
| inherit | Specifies that the border property value should be inherited from the parent element |
Related Articles
CSS Tutorial: CSS Borders