Home > Web Front-end > CSS Tutorial > How to Add Spacing Between Rows in a Table Without Using Border-Spacing?

How to Add Spacing Between Rows in a Table Without Using Border-Spacing?

Patricia Arquette
Release: 2024-11-10 02:30:02
Original
930 people have browsed it

How to Add Spacing Between Rows in a Table Without Using Border-Spacing?

Spacing Rows in a Table

Adding vertical spacing between table rows enhances readability and visual appeal. While border-spacing may seem like the ideal property for this purpose, it only affects the spacing between table cells. To achieve row spacing, we must explore alternative solutions.

The key lies in adjusting the padding of individual table data cells ( elements). Here's a CSS solution:

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

In this code, we target direct children (>) of table rows with the class "spaceUnder." This allows for selective spacing, which can be useful in nested table scenarios.

The "padding-bottom" property defines the vertical spacing below the cell contents. Adjust this value as desired to achieve the preferred row spacing. By padding the bottom of the cell, we effectively create a gap between the cell and the row below it.

So, while border-spacing is not applicable in this case, padding provides an effective means to control row spacing in tables.

The above is the detailed content of How to Add Spacing Between Rows in a Table Without Using Border-Spacing?. For more information, please follow other related articles on the PHP Chinese website!

source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Latest Articles by Author
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template