Style borderSpacing Property

Style Object Reference Style Object


Set the space between cells in a table:

document.getElementById("myTable").style.borderSpacing = "20px";

Try it yourself »

Definition and Usage

The borderSpacing property sets or returns the space between cells in a table.

Note: This property has no effect if borderCollapse is set to collapse.

Browser Support

Internet Explorer Firefox Opera Google Chrome Safari

The borderSpacing property is supported in all major browsers.

Note: The borderSpacing property is not supported in IE7 and earlier. IE8 requires a !DOCTYPE. IE9 supports it.


Return the borderSpacing property:

Set the borderSpacing property:"length length|initial|inherit"

Property Values

Value Description
length length Specifies the space between cells in length units. Negative values are not allowed. Default value is 0.
  • If one length value is specified, it specifies 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. Read about initial
inherit Inherits this property from its parent element. Read about inherit

Technical Details

Default Value: 0
Return Value: A String, representing the space between cells in a table
CSS Version CSS2

More Examples


Return the space between cells in a table:


Try it yourself »

Related Pages

CSS tutorial: CSS Table

CSS reference: border-spacing property

Style Object Reference Style Object