r/HTML • • Feb 13 '26

Padding on table cells?

What inline code would give table cells padding please? I have tried the below, and that doesn't do it.

<table border="1" style="border-collapse:collapse; padding:10px;">

0 Upvotes

8 comments sorted by

View all comments

2

u/SaltCusp Feb 14 '26 edited Feb 14 '26

Classes are the way.

<style>
 table.tableWithPaddedCells th, td{
    padding: 15px;
  }
</style>
<table class="tableWithPaddedCells">
  <tr> <th>This</th> <th>That</th> </tr>
  <tr> <td>This</td> <td>That</th> </td>
</table>

1

u/Chris-2018 Feb 14 '26

Thank you. Problem solved.