cellpadding (HTML attribute)

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

Syntax

cellpadding="number"

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.

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

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.

Related Products