Skip to: content, navigation

by Tommy Olsson and Paul O’Brien

border-spacing (CSS property)

Browser support full matrix
IE7 FF1+ Saf1.3+ Op9.2+
None Full Full Full
Spec
Inherited Initial Version
Yes CSS2
border-spacing: { length  [ length ] | inherit } ;

Example

This style rule sets 1em of horizontal spacing and 0.5em of vertical spacing between the cells of the table element with the ID "results":

#results {
  border-collapse: separate;
  border-spacing: 1em 0.5em;
}

Try it yourself!View all demos

Description

This property sets the spacing between adjacent table cells’ borders using the separated borders model. If the collapsing borders model is used, this property is ignored.

Note that the distance between a cell border and the table border is the corresponding border spacing plus the table’s padding for that side.

See Table Formatting for details about the table border models.

The CSS2.1 specification states that user agents may apply this property to frameset elements (therefore replacing the framespacing attribute).

Value

Negative values are not allowed.

The border spacing can be specified using one or two length values. If two values are given, the first sets the horizontal spacing, and the second sets the vertical spacing. If only one value is given, it sets both the horizontal and vertical spacing to the specified value.

Compatibility

IE5.5None
6.0None
7.0None
Firefox1.0Full
1.5Full
2.0Full
Safari1.3Full
2.0Full
3.0Full
Opera9.2Full
9.5Full

Internet Explorer for Windows versions up to and including 7 do not support this property.

Related Reading

User-contributed notes

There are no comments yet.

Add a note

To post a note on this topic, please log in with your SitePoint username and password. If you don't have an account yet, you can create a new account for free.

Related Products

The Principles of Beautiful Web Design

Best Seller!

You don’t need to go to Art School to design great looking web sites!

Book Cover: The Principles of Beautiful Web Design

Download the FREE sample chapters