Latest web development tutorials

HTML DOM Style borderSpacing property

Style Object Reference Style Objects

Examples

Set the distance between the cells in the table:

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

try it"

Definition and Usage

borderSpacing property sets or returns the distance between the cells of the table.

Note: If borderCollapse set to collapse, then the property does not work.


Browser Support

Internet ExplorerFirefoxOperaGoogle ChromeSafari

All major browsers support borderSpacing property.

Note: IE7 and earlier versions do not support borderSpacing property.IE8 requires a! DOCTYPE. IE9 support this property.


grammar

Back borderSpacing properties:

object .style.borderSpacing

Setting borderSpacing properties:

object .style.borderSpacing="length length|initial|inherit"

Property Values

描述
length length 以长度单位形式规定单元格之间的距离。不允许使用负值。默认值是 0。
  • 如果指定了一个长度值,那么规定的是水平和垂直间距。
  • 如果指定了两个长度值,那么第一个设置水平间距,第二个设置垂直间距。
initial 设置该属性为它的默认值。请参阅 initial
inherit 从父元素继承该属性。请参阅 inherit

technical details

Defaults: 0
return value: String that represents the distance between the cells in a table.
CSS version CSS2


More examples

Examples

Returns the distance between cells in a table:

alert(document.getElementById("myTable").style.borderSpacing);

try it"


related articles

CSS tutorial: CSS the Table (table)

CSS Reference: border-spacing property


Style Object Reference Style Objects