| Depr. | Version |
|---|---|
| No | HTML 2 |
| IE5.5+ | FF1+ | SA1.3+ | OP9.2+ | CH2+ |
|---|---|---|---|---|
| Full | Full | Full | Full | Full |
Syntax
Description
Use
the cellpadding attribute to create some space
around the contents of table cells (in th and td elements). The
effect of this attribute’s application won’t be immediately obvious unless
you’ve also set a border
attribute for the table, as Figure 1 reveals.
The
cellpadding attribute is similar to the cellspacing attribute, which is used to create
space between and outside of the table cells.
Example
The
cellpadding for this table is
set to "5" pixels:
<table border="1" cellpadding="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 |
This
attribute suffers no compatibility problems—excellent browser support is
provided for it. However, you’re advised to use the CSS
padding property to set padding on
th and td elements, as it’s easy to
do, is also well supported, and offers greater flexibility than does
cellpadding.
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.