| Depr. | Version |
|---|---|
| No | HTML 2 |
| IE5.5+ | FF1+ | SA1.3+ | OP9.2+ | CH2+ |
|---|---|---|---|---|
| Full | Full | Full | Full | Full |
Syntax
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.
cellspacing values of
five and ten pixels, respectively
There is a CSS-based alternative to the HTML
cellspacing attribute, called border-spacing, but it is
not supported by Internet Explorer (even in version 8). You may use the
CSS border-collapse property, setting it to
"collapse", which removes the need for a
cellspacing value of "0", but
does not solve the problem of setting larger cell spacing values. So while
it’s usually better to use the CSS approach, it may not possible for this
particular attribute, depending on what you are trying to achieve with
your tables, 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 | Chrome | ||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 5.5 | 6.0 | 7.0 | 8.0 | 1.0 | 1.5 | 2.0 | 3.0 | 3.5 | 1.3 | 2.0 | 3.1 | 4.0 | 9.2 | 9.5 | 10.0 | 2.0 |
| Full | Full | Full | Full | Full | Full | 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.