Style borderSpacingProperty

Style 对象参考手册Style Object

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

Internet Explorer Firefox Opera Google Chrome Safari

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.
  • If one length value is specified, it sets both the horizontal and vertical spacing.
  • If two length values are specified, the first sets the horizontal spacing, and the second sets the vertical spacing.
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


Style 对象参考手册Style Object

Other Extensions