Categories
CSS

How to add space between two rows in a table with CSS?

Spread the love

Sometimes, we want to add space between two rows in a table with CSS.

In this article, we’ll look at how to add space between two rows in a table with CSS.

How to add space between two rows in a table with CSS?

To add space between two rows in a table with CSS, we set the padding.

For instance, we write

<table>
  <tbody>
    <tr>
      <td>A</td>
      <td>B</td>
    </tr>
    <tr class="spaceUnder">
      <td>C</td>
      <td>D</td>
    </tr>
    <tr>
      <td>E</td>
      <td>F</td>
    </tr>
  </tbody>
</table>

to add a table.

‘Then we write

tr.spaceUnder > td {
  padding-bottom: 1em;
}

to add some bottom padding to the tr with class spaceUnder.

Conclusion

To add space between two rows in a table with CSS, we set the padding.

By John Au-Yeung

Web developer specializing in React, Vue, and front end development.

Leave a Reply

Your email address will not be published. Required fields are marked *