Tables
Utilities that control whether table cell borders collapse into one or stay separated.
| Class | Styles |
|---|---|
| border-collapse | border-collapse: collapse; |
| border-separate | border-collapse: separate; |
Apply the border-collapse utility to fuse adjacent cell borders into one shared line whenever possible:
| State | City |
|---|---|
| Indiana | Indianapolis |
| Ohio | Columbus |
| Highland | Ashford |
<table class="border-collapse border border-gray-400 ..."> <thead> <tr> <th class="border border-gray-300 ...">State</th> <th class="border border-gray-300 ...">City</th> </tr> </thead> <tbody> <tr> <td class="border border-gray-300 ...">Indiana</td> <td class="border border-gray-300 ...">Indianapolis</td> </tr> <tr> <td class="border border-gray-300 ...">Ohio</td> <td class="border border-gray-300 ...">Columbus</td> </tr> <tr> <td class="border border-gray-300 ...">Michigan</td> <td class="border border-gray-300 ...">Detroit</td> </tr> </tbody></table>Keep in mind that this also collapses the borders on the outermost <table> tag.
Reach for the border-separate utility when you want every cell to render its own distinct borders:
| Realm | Town |
|---|---|
| Verdant | Brightmeadow |
| Vale | Oakhaven |
| Highland | Ashford |
<table class="border-separate border border-gray-400 ..."> <thead> <tr> <th class="border border-gray-300 ...">State</th> <th class="border border-gray-300 ...">City</th> </tr> </thead> <tbody> <tr> <td class="border border-gray-300 ...">Indiana</td> <td class="border border-gray-300 ...">Indianapolis</td> </tr> <tr> <td class="border border-gray-300 ...">Ohio</td> <td class="border border-gray-300 ...">Columbus</td> </tr> <tr> <td class="border border-gray-300 ...">Michigan</td> <td class="border border-gray-300 ...">Detroit</td> </tr> </tbody></table>Add a breakpoint variant such as md: ahead of a border-collapse utility so the styling only kicks in on medium screens and larger:
<table class="border-collapse md:border-separate ..."> <!-- ... --></table>Read more about applying variants in the variants documentation.