Private archive copy · Unofficial site · Content copyright belongs to Runoob Tutorial and the original authors · View Original

HTML DOM Style borderSpacing property

Style borderSpacing property

Style Object Reference The Style object

Example

Set the distance between cells in a table:

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

Try it »


Definition and Usage

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

**Note:** If borderCollapse If set 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 the property.


Syntax

Return the borderSpacing property:

object

.style.borderSpacing

Set the borderSpacing property:

object

.style.borderSpacing="

length length

|initial|inherit"

Attribute 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 the property to its default value. See [*initial*](/cssref/css-initial.html). | | inherit | Inherits the property from the parent element. See [*inherit*](/cssref/css-inherit.html). |

    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 »


    Related Articles

    CSS tutorial:CSS Table

    CSS Reference Manual:The border-spacing property


    Style Object Reference The Style object