Style borderWidth Property
- Previous Page borderTopWidth
- Next Page bottom
- Go Up One Level HTML DOM Style Object
Definition and Usage
borderWidth
This property sets or returns the width of the element's border.
This property can take one to four values:
- A value, for example: p {border-width: thick} - All four borders are thick
- Two values, for example: p {border-width: thick thin} - The top and bottom borders are thick, and the left and right borders are thin
- Three values, for example: p {border-width: thick thin medium} - The top border is thick, the left and right borders are thin, and the bottom border is medium
- Four values, for example: p {border-width: thick thin medium 10px} - The top border is thick, the right border is thin, the bottom border is medium, and the left border is 10px
See also:
CSS Tutorial:CSS Borders
CSS Reference Manual:border-width property
HTML DOM Reference Manual:border property
Instance
Example 1
Changes the width of the four borders of the <div> element:
document.getElementById("myDiv").style.borderWidth = "thick";
Example 2
Changes the top and bottom border widths of the <div> element to thick and the left and right border widths to thin:
document.getElementById("myDiv").style.borderWidth = "thick thin";
Example 3
Use length values to change the width of the four borders of the <div> element:
document.getElementById("myDiv").style.borderWidth = "1px 5px 10px 20px";
Example 4
Returns the border width of the <div> element:
alert(document.getElementById("myDiv").style.borderWidth);
Syntax
Return borderWidth property:
object.style.borderWidth
Set borderWidth property:
object.style.borderWidth = "thin|medium|thick|length|initial|inherit"
Value | Description |
---|---|
thin | Defines thin borders. |
medium | Defines medium borders. Default. |
thick | Defines thick borders. |
length | Border width measured in length. |
initial | Sets this property to its default value. See initial. |
inherit | Inherits this property from its parent element. See inherit. |
Technical Details
Default value: | medium |
---|---|
Return value: | A string that represents the width of the element's border. |
CSS Version: | CSS1 |
Browser Support
Chrome | Edge | Firefox | Safari | Opera |
---|---|---|---|---|
Chrome | Edge | Firefox | Safari | Opera |
Support | Support | Support | Support | Support |
- Previous Page borderTopWidth
- Next Page bottom
- Go Up One Level HTML DOM Style Object