CSS border-spacing 属性

Course recommendation:

Definition and usage

border-spacing property sets the distance between the borders of adjacent cells (only used for 'separated' mode).Note:

Some versions of the IE browser do not support this property.

Description

This property specifies the distance between the cell boundaries in the separated border model. In the two specified length values, the first is the horizontal interval, and the second is the vertical interval. This property is ignored unless border-collapse is set to separate. Although this property is only applied to tables, it can be inherited by all elements in the table.

See also:Talaan ng CSS

CSS tutorial:HTML DOM reference manual:

borderSpacing attribute

Example

Set border-spacing for the table:
  table
  {
  border-collapse:separate;
  border-spacing:10px 50px;

}

Try it yourself

CSS grammar lengthborder-spacing:

|initial|inherit;

Attribute value Value
Description

length length

Specifies the distance between the borders of adjacent cells. Use units such as px, cm, etc. Negative values are not allowed. length If one parameter is defined

If two parameters are defined, the defined is the horizontal and vertical spacing. length If two parameters are specified, the first sets the horizontal spacing, and the second sets the vertical spacing.

inherit Specifies that the border-spacing property should inherit its value from the parent element.

Technical details

Default value: not specified
Inheritance: yes
Version: CSS2
JavaScript grammar: object.style.borderSpacing="15px"

更多範例

設定表格邊框之間的空白
此範例演示如何設定單元格邊框之間的距離。

browser support

Chrome IE / Edge Firefox Safari Opera
1.0 8.0 1.0 1.0 4.0