cellpadding (HTML attribute)

Tweet

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.

Two tables, with cellpadding values of five and ten pixels, respectively

Two tables, with cellpadding values of five and ten pixels, respectively

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.

Learn HTML5 Online

Get all SitePoint books and courses with a Learnable membership. Start building future-proof websites that are faster, more powerful, and easier to maintain.

No Reader comments