If you want to achieve this using css pseudo-classes, it is totally doable
For more detailed information, check out: Css pseudo-classes
Your HTML structure remains the same:
<table class="table">
<tbody class="table-body">
<tr class="row">
<td class="cell">Cool</td>
<td class="cell">Cool</td>
</tr>
<tr class="row">
<td class="cell">Cool</td>
<td class="cell">Cool</td>
</tr>
</tbody>
</table>
In your css file:
.table {
border-collapse: collapse;
border-style: hidden;
}
.cell {
padding: 5px 10px;
}
.row:nth-of-type(1n+1) {
border-bottom: 2px solid pink;
}
.cell:nth-of-type(2n-1) {
border-right: 2px solid pink;
}
Explanation for the css styling:
To add top borders, we skip the first row:
.row:nth-of-type(1n+1) {
border-bottom: 2px solid pink;
}
Then, only apply borders to odd cells:
.cell:nth-of-type(2n-1) {
border-right: 2px solid pink;
}
Check out the code implementation here: Code here
I hope this explanation helps you in achieving your desired design.
Update: I apologize for missing the fact that you are not utilizing table tags. In that case, follow Hải Bùi's solution as my css code is specifically tailored for tables.