Set the style of the borders for different elements:
h1 {
border: 5px solid red;
}
h2 {
border: 4px dotted blue;
}
div {
border: double;
}
Try it Yourself »
The border
property is a shorthand property for:
If border-color is omitted, the color applied will be the color of the text.
Default value: | medium none color |
---|---|
Inherited: | no |
Animatable: | yes, see individual properties. Read about animatable Try it |
Version: | CSS1 |
JavaScript syntax: | object.style.border="3px solid blue" Try it |
The numbers in the table specify the first browser version that fully supports the property.
Property | |||||
---|---|---|---|---|---|
border | 1.0 | 4.0 | 1.0 | 1.0 | 3.5 |
border:
border-width
border-style
border-color|initial|inherit;
Value | Description | Demo |
---|---|---|
border-width | Specifies the width of the border. Default value is "medium" | Demo ❯ |
border-style | Specifies the style of the border. Default value is "none" | Demo ❯ |
border-color | Specifies the color of the border. Default value is the color of the text | Demo ❯ |
initial | Sets this property to its default value. Read about initial | |
inherit | Inherits this property from its parent element. Read about inherit |
CSS tutorial: CSS Border
CSS tutorial: CSS Box Model
HTML DOM reference: border property
截取页面反馈部分,让我们更快修复内容!也可以直接跳过填写反馈内容!