border-spacing

border-spacing

The border-spacing CSS property specifies the distance between the borders of adjacent table cells (only for the separated borders model). This is equivalent to the cellspacing attribute in presentational HTML, but an optional second value can be used to set different horizontal and vertical spacing.

The border-spacing value is also used along the outside edge of the table, where the distance between the table's border and the cells in the first/last column or row is the sum of the relevant (horizontal or vertical) border-spacing and the relevant (top, right, bottom, or left) padding on the table.

This property applies only when border-collapse is separate.

Initial value 0
Applies to table and inline-table elements
Inherited yes
Media visual
Computed value two absolute lengths
Animation type discrete
Canonical order the unique non-ambiguous order defined by the formal grammar

Syntax

/* border-spacing: length */
border-spacing: 2px;

/* border-spacing: horizontal vertical */
border-spacing: 1cm 2em;

border-spacing: inherit;

Values

length
Is a <length> value that describes both the horizontal and vertical spacings between cells. It is used only in the one-value syntax.
horizontal
Is a <length> value that describes the horizontal spacing between cells, that is the space between cells in adjacent columns. It is used only in the two-value syntax.
vertical
Is a <length> value that describes the vertical spacing between cells, that is the space between cells in adjacent rows. It is used only in the two-value syntax.
inherit
Is a keyword indicating that the calculated value of border-spacing of the parent's element must be used.

Formal syntax

<length> <length>?

Examples

css

table { border-spacing: 5px 10px; }

Result

Specifications

Specification Status Comment
CSS Level 2 (Revision 1)
The definition of 'border-spacing' in that specification.
Recommendation Initial definition

Browser compatibility

Feature Chrome Edge Firefox (Gecko) Internet Explorer Opera Safari (WebKit)
Basic support 1.0 (Yes) 1.0 (1.7 or earlier) 8.0 4.0 1.0 (85)
Feature Android Edge Firefox Mobile (Gecko) IE Phone Opera Mobile Safari Mobile
Basic support ? (Yes) 1.0 (1.9.2) ? ? ?

© 2005–2017 Mozilla Developer Network and individual contributors.
Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.
https://developer.mozilla.org/en-US/docs/Web/CSS/border-spacing

在线笔记
App下载
App下载

扫描二维码

下载编程狮App

公众号
微信公众号

编程狮公众号

意见反馈
返回顶部