Style borderSpacingProperty
Example
Set the distance between cells in a table:
document.getElementById("myTable").style.borderSpacing="20px";
Try it yourself »
Definition and Usage
The borderSpacing property sets or returns the distance between cells in a table.
Note:IfborderCollapseset to "collapse", this property has no effect.
Browser Support
![]()
All major browsers support the borderSpacing property.
Note:IE7 and earlier versions do not support the borderSpacing property. IE8 requires a !DOCTYPE. IE9 supports this property.
Syntax
Return the borderSpacing property:
object.style.borderSpacing
Set the borderSpacing property:
object.style.borderSpacing="length length|initial|inherit"
Property Values
| Value | Description |
|---|---|
| length length | Specifies the distance between cells in length units. Negative values are not allowed. The default value is 0.
|
| initial | Sets this property to its default value. Seeinitial。 |
| inherit | Inherits this property from its parent element. Seeinherit。 |
Technical Details
| Default Value: | 0 |
|---|---|
| Return Value: | A string, representing the distance between cells in a table. |
| CSS Version | CSS2 |
More Examples
Example
Return the distance between cells in a table:
alert(document.getElementById("myTable").style.borderSpacing);
Try it yourself »
Related Articles
CSS Tutorial:CSS Table
CSS Reference:border-spacing Property
Other Extensions
Style Object