English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية
The CSS border property sets the width, style, and color of all four sides of the element's border. It is used to set border properties individually, that is, a shorthand property, andborder-width,border-styleandborder-coloris a single declaration.
The following table summarizes the usage context and version history of this attribute.
Default Value: | View individual properties |
---|---|
Applicable To: | All Elements |
Inheritance: | No |
Animatable: | Yes,See individual properties.See Animation Properties. |
Version: | CSS 1,2,3 |
JavaScript Syntax: | object object.style.border="1px solid red" |
The syntax of this attribute is as follows:
border: [ border-width border-style border-color ] | initial | inherit
Note:If any of the listed properties are missing or omitted, the default value of the property (if any) will be inserted. For more details, see each property.
The following examples demonstrate how to use the border property.
h1 { border: 5px solid #ff0000;} p { color: #00ff00; border: 5px solid;}Test and see‹/›
Note:Ifborder-colormissing or not specified (for example, border: 5px solid;),colorthen the value of the element attribute will be used. However, in the presence ofborder-styleIn this case, skipping or ignoring this value will not display any border because the border-The default value of the style attribute is none.
The following table describes the values of this property.
Value | Description |
---|---|
border-width | Set the width of the element border. |
border-style | Set the line style of the element border. |
border-color | Set the color of the element border. |
initial | Set this property to its default value. |
inherit | If specified, the associated elements use the calculated value of the parent element's border property. |
Browser Compatibility of border Property, all mainstream browsers support this property.
|
See Tutorial:CSS Border,CSS3 Border.
Related Properties:border-width,border-style,border-color,border-collapse,border-image,border-radius,border-spacing.