Skip to: content, navigation

cellspacing (HTML attribute)

Spec
Depr. Version
No HTML 2
Browser support (more…)
IE5.5+ FF1+ SA1.3+ OP9.2+
Full Full Full Full

Syntax

cellspacing="number"

Description

The cellspacing attribute is used to create space around (that is, outside of) table cells. Think of table cells as bricks, and the cellspacing as the mortar in between. You can change the thickness of that mortar by altering the cellspacing value, as Figure 1 shows.

Figure 1. Two tables, with cellspacing values of five and ten pixels, respectively Two tables, with cellspacing values of 5 and 10 pixels, respectively (for comparison)

There is a CSS-based alternative to the HTML cellspacing attribute, called border-spacing, but it is not supported by Internet Explorer versions 7 and earlier. So while it’s usually better to use the CSS approach, that’s not possible for this particular attribute without ignoring what is currently the most commonly used browser.

The cellspacing attribute is similar to the cellpadding attribute, which is used to create space around the content inside table cells.

Example

The cellspacing for this table is set to "5" pixels:

<table border="1" cellspacing="5">
  <tr>
    <th>Account Type</th>
    <th>Interest Rate</th>
  </tr>
  <tr>
    <td>Smart</td>
    <td>From 2%</td>
  </tr>
  <tr>
    <td>Young Saver</td>
    <td>From 1.6%</td>
  </tr>
</table>

Value

This attribute takes a numerical value, which reflects a pixel measurement.

Compatibility

Internet Explorer Firefox Safari Opera
5.5 6.0 7.0 1.0 1.5 2.0 1.3 2.0 3.0 9.2 9.5
Full Full Full Full Full Full Full Full Full Full Full

It causes no compatibility issues, and has excellent support across all tested browsers.

User-contributed notes

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

Search