🤯 50% Off! 700+ courses, assessments, and books

cellpadding (HTML attribute)

Adam Roberts
Share

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.