English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية

CSS Reference Manual

CSS @rules (RULES)

All CSS properties

CSS border-Usage and examples of the 'spacing' property

border-The 'spacing' CSS property uses the separated border model to set the spacing between adjacent table cell borders. If the collapsed border model is used, this property will be ignored. Please seeborder-collapseProperty.

The table below provides usage instructions and version history for this property, as well as the syntax for using this property in JavaScript scripts.

Default value:0
Applies to:tableand inline table (inline-table) element
Inheritance:Yes
Can be animated:Yes.Please refer to Animation properties.
Version:CSS 2,3
JavaScript syntax:object object.style.borderSpacing="12px"

border-The syntax of spacing

The syntax of this attribute is as follows:

border-spacing: [ length ] 1 or 2 values | initial | inherit

this border-The spacing attribute can take one or two space-separated length values.

  • If specifiedone valuetheValueThe two values will be applied to both horizontal and vertical border spacing.

  • If specifiedtwo valuesIf specified, the first sets the horizontal border spacing, and the second sets the vertical border spacing.

The following example demonstrates how to use border-spacing attribute.

  table {
   border-collapse: separate;
   border-spacing: 10px 20px;
  }
Test to see‹/›

Attribute value

The following table describes the value of this attribute.

ValueDescription
lengthThe length values such as px, pt, cm, em, etc., do not allow negative values.
initialSet this attribute to its default value.
inheritIf specified, the associated element adopts the border of its parent element-The value of the spacing attribute.

Browser compatibility

border-The compatibility of the spacing attribute of browsers, the numbers in the following table represent the minimum version number of the browser that supports this attribute; all mainstream browsers support this attribute.

  • Firefox 1+

  • Google Chrome1+

  • Internet Explorer 8+

  • Apple Safari 1+

  • Opera 4+

Warning: Internet Explorer 7and earlier versions do not support this border-spacing attribute. IE8Only in<!DOCTYPE>This attribute is supported only when a is specified.

For further reading

Please refer to the following tutorials:CSS table,CSS border,CSS3Border.

Table-related attributes:border-collapse,empty-cells,table-layout.