Style border property
- Previous page backfaceVisibility
- Next page borderBottom
- Go back to the previous level HTML DOM Style Object
Definition and Usage
border
Properties set or returned in shorthand form, up to three separate border properties.
With this property, you can set/return the following one or more (in any order):
See also:
CSS Tutorial:CSS Border
CSS Reference Manual:border Property
Example
Example 1
Add a border to the <div> element:
document.getElementById("myDiv").style.border = "thick solid #0000FF";
Example 2
Change the width, style, and color of the <div> element's border:
document.getElementById("myDiv").style.border = "thin dotted red";
Example 3
Return the border property value of the <div> element:
alert(document.getElementById("myDiv").style.border);
Syntax
Return border property:
object.style.border
Set border property:
object.style.border = "width style color|initial|inherit"
Property Value
Value | Description |
---|---|
width | Set the border width. |
style | Set the border style. |
color | Set the border color. |
initial | Set this property to its default value. See initial. |
inherit | Inherit this property from its parent element. See inherit. |
Technical Details
Default value: | Not specified. |
---|---|
Return value: | A string representing the element's border width, style, and/or color. |
CSS Version: | CSS1 |
Browser support
border
It is a CSS1 (1996) feature.
All browsers fully support it:
Chrome | Edge | Firefox | Safari | Opera | IE |
---|---|---|---|---|---|
Chrome | Edge | Firefox | Safari | Opera | IE |
Support | Support | Support | Support | Support | Support |
- Previous page backfaceVisibility
- Next page borderBottom
- Go back to the previous level HTML DOM Style Object