Tags
Asked 3 years ago
7 Jul 2021
Views 261
Arden

Arden posted

Cellpadding in one html table cell

Cellpadding in one html table cell
Nilesh

Nilesh
answered May 1 '23 00:00

The cellpadding attribute sets the amount of space between the cell content and the cell border . To apply cellpadding to only one cell in an HTML table, you can use CSS to target that cell and apply a padding to it.

First, add a class or ID to the table cell you want to add padding to:


<table>
  <tr>
    <td>Cell 1</td>
    <td class="padded-cell">Cell 2</td>
    <td>Cell 3</td>
  </tr>
</table>

Then, in your CSS file, add the following rule:

.padded-cell {
  padding: 10px;
}

This will apply a 10 pixel padding to the cell with the class padded-cell. You can adjust the value to suit your needs.

Alternatively, you can apply inline styles directly to the cell:


<table>
  <tr>
    <td>Cell 1</td>
    <td style="padding: 10px;">Cell 2</td>
    <td>Cell 3</td>
  </tr>
</table>

This will apply a 10 pixel padding to the second cell in the table row.
Post Answer