Tables show up everywhere in web apps.
Data dashboards need them. Pricing pages use them. Admin panels can't live without them. They organize information in a way that makes sense to our brains.
But here's the problem: default HTML tables look terrible. Gray borders, cramped spacing, zero personality. It's like they're stuck in 1995.
Good news though. With Tailwind CSS, you can turn those boring tables into something people actually want to look at. And you don't need to write a single line of custom CSS to do it.
Let's start simple. A good-looking table needs proper structure first, then styling second.
Your table should have <thead> for headers and <tbody> for data rows. This isn't just semantic HTML nonsense. It actually helps with styling because you can target these sections differently.
Here's where Tailwind shines. You can add padding, borders, and colors directly in your markup.
The first decision you'll make is about borders. Tailwind gives you two options:
border-collapse merges adjacent cell borders into oneborder-separate keeps each cell border distinctMost of the time, you want border-collapse. It looks cleaner and prevents that weird double-border effect.
<table class='w-full border-collapse border border-gray-300'>
<thead>
<tr class='bg-gray-100'>
<th class='border border-gray-300 px-4 py-2 text-left'>Product</th>
<th class='border border-gray-300 px-4 py-2 text-left'>Price</th>
<th class='border border-gray-300 px-4 py-2 text-left'>Stock</th>
</tr>
</thead>
<tbody>
<tr>
<td class='border border-gray-300 px-4 py-2'>Laptop</td>
<td class='border border-gray-300 px-4 py-2'>$999</td>
<td class='border border-gray-300 px-4 py-2'>In Stock</td>
</tr>
<tr>
<td class='border border-gray-300 px-4 py-2'>Mouse</td>
<td class='border border-gray-300 px-4 py-2'>$29</td>
<td class='border border-gray-300 px-4 py-2'>Low Stock</td>
</tr>
<tr>
<td class='border border-gray-300 px-4 py-2'>Keyboard</td>
<td class='border border-gray-300 px-4 py-2'>$79</td>
<td class='border border-gray-300 px-4 py-2'>In Stock</td>
</tr>
</tbody>
</table>Notice how px-4 py-2 gives each cell breathing room. Without padding, your data looks cramped and hard to read. The bg-gray-100 on the header row helps distinguish it from the body.
That's your foundation. Clean structure, consistent borders, good spacing.
Zebra stripes aren't just for animals. They make tables way easier to read, especially when you're scanning across long rows of data.
Tailwind makes this stupid simple with the odd: and even: variants. Just add them to your table rows.
Want every other row to be gray? Use odd:bg-gray-50 on your <tr> tags. Done.
<table class='w-full border-collapse'>
<thead>
<tr class='bg-gray-200'>
<th class='px-4 py-3 text-left font-semibold'>Name</th>
<th class='px-4 py-3 text-left font-semibold'>Email</th>
<th class='px-4 py-3 text-left font-semibold'>Role</th>
</tr>
</thead>
<tbody>
<tr class='odd:bg-gray-50'>
<td class='px-4 py-2'>John Doe</td>
<td class='px-4 py-2'>john@example.com</td>
<td class='px-4 py-2'>Admin</td>
</tr>
<tr class='odd:bg-gray-50'>
<td class='px-4 py-2'>Jane Smith</td>
<td class='px-4 py-2'>jane@example.com</td>
<td class='px-4 py-2'>Editor</td>
</tr>
<tr class='odd:bg-gray-50'>
<td class='px-4 py-2'>Bob Johnson</td>
<td class='px-4 py-2'>bob@example.com</td>
<td class='px-4 py-2'>Viewer</td>
</tr>
<tr class='odd:bg-gray-50'>
<td class='px-4 py-2'>Sarah Williams</td>
<td class='px-4 py-2'>sarah@example.com</td>
<td class='px-4 py-2'>Editor</td>
</tr>
</tbody>
</table>Hover effects are just as easy. Add hover:bg-blue-50 to your rows and they'll highlight when users mouse over them. This is huge for usability – it helps people keep track of which row they're looking at.
You can combine both. Striped rows plus hover state:
<table class='w-full border-collapse'>
<thead>
<tr class='bg-blue-600 text-white'>
<th class='px-4 py-3 text-left font-semibold'>Product</th>
<th class='px-4 py-3 text-left font-semibold'>Category</th>
<th class='px-4 py-3 text-left font-semibold'>Sales</th>
</tr>
</thead>
<tbody>
<tr class='odd:bg-gray-50 hover:bg-blue-50 cursor-pointer transition-colors'>
<td class='px-4 py-2'>MacBook Pro</td>
<td class='px-4 py-2'>Laptops</td>
<td class='px-4 py-2'>1,234</td>
</tr>
<tr class='odd:bg-gray-50 hover:bg-blue-50 cursor-pointer transition-colors'>
<td class='px-4 py-2'>iPhone 15</td>
<td class='px-4 py-2'>Phones</td>
<td class='px-4 py-2'>3,456</td>
</tr>
<tr class='odd:bg-gray-50 hover:bg-blue-50 cursor-pointer transition-colors'>
<td class='px-4 py-2'>AirPods Pro</td>
<td class='px-4 py-2'>Audio</td>
<td class='px-4 py-2'>2,789</td>
</tr>
<tr class='odd:bg-gray-50 hover:bg-blue-50 cursor-pointer transition-colors'>
<td class='px-4 py-2'>iPad Air</td>
<td class='px-4 py-2'>Tablets</td>
<td class='px-4 py-2'>987</td>
</tr>
</tbody>
</table>I threw in cursor-pointer and transition-colors too. The pointer cursor tells users the row is interactive, and the transition makes the color change smooth instead of jarring.
Tables on mobile are a nightmare. They're wide, they break layouts, and they make users scroll horizontally – which nobody likes doing.
The simplest fix is wrapping your table in a container with overflow-x-auto. This lets users scroll the table horizontally while keeping your page layout intact.
<div class='overflow-x-auto border border-gray-300 rounded-lg'>
<table class='w-full border-collapse'>
<thead>
<tr class='bg-gray-100'>
<th class='px-4 py-2 text-left whitespace-nowrap'>Employee</th>
<th class='px-4 py-2 text-left whitespace-nowrap'>Position</th>
<th class='px-4 py-2 text-left whitespace-nowrap'>Department</th>
<th class='px-4 py-2 text-left whitespace-nowrap'>Location</th>
<th class='px-4 py-2 text-left whitespace-nowrap'>Salary</th>
</tr>
</thead>
<tbody>
<tr class='border-t'>
<td class='px-4 py-2 whitespace-nowrap'>Sarah Connor</td>
<td class='px-4 py-2 whitespace-nowrap'>Engineering Lead</td>
<td class='px-4 py-2 whitespace-nowrap'>Product Development</td>
<td class='px-4 py-2 whitespace-nowrap'>San Francisco</td>
<td class='px-4 py-2 whitespace-nowrap'>$145,000</td>
</tr>
<tr class='border-t'>
<td class='px-4 py-2 whitespace-nowrap'>John McClane</td>
<td class='px-4 py-2 whitespace-nowrap'>Security Director</td>
<td class='px-4 py-2 whitespace-nowrap'>Operations</td>
<td class='px-4 py-2 whitespace-nowrap'>New York</td>
<td class='px-4 py-2 whitespace-nowrap'>$132,000</td>
</tr>
<tr class='border-t'>
<td class='px-4 py-2 whitespace-nowrap'>Ellen Ripley</td>
<td class='px-4 py-2 whitespace-nowrap'>Chief Science Officer</td>
<td class='px-4 py-2 whitespace-nowrap'>Research</td>
<td class='px-4 py-2 whitespace-nowrap'>Houston</td>
<td class='px-4 py-2 whitespace-nowrap'>$158,000</td>
</tr>
</tbody>
</table>
</div>Notice the whitespace-nowrap on the cells. This prevents text from wrapping, which keeps your columns readable when scrolling.
You can also adjust table behavior at different breakpoints. Maybe you want a fixed layout on desktop but auto layout on mobile:
<div class='space-y-4'>
<p class='text-sm text-gray-600'>On mobile this table uses auto layout, on larger screens it switches to fixed layout:</p>
<div class='overflow-x-auto border border-gray-300 rounded-lg'>
<table class='w-full border-collapse table-auto md:table-fixed'>
<thead>
<tr class='bg-blue-600 text-white'>
<th class='px-4 py-2 text-left'>Feature</th>
<th class='px-4 py-2 text-left'>Basic</th>
<th class='px-4 py-2 text-left'>Pro</th>
<th class='px-4 py-2 text-left'>Enterprise</th>
</tr>
</thead>
<tbody>
<tr class='border-t'>
<td class='px-4 py-2 font-medium'>Users</td>
<td class='px-4 py-2'>Up to 5</td>
<td class='px-4 py-2'>Up to 25</td>
<td class='px-4 py-2'>Unlimited</td>
</tr>
<tr class='border-t bg-gray-50'>
<td class='px-4 py-2 font-medium'>Storage</td>
<td class='px-4 py-2'>10 GB</td>
<td class='px-4 py-2'>100 GB</td>
<td class='px-4 py-2'>1 TB</td>
</tr>
<tr class='border-t'>
<td class='px-4 py-2 font-medium'>Support</td>
<td class='px-4 py-2'>Email</td>
<td class='px-4 py-2'>Email + Chat</td>
<td class='px-4 py-2'>24/7 Priority</td>
</tr>
</tbody>
</table>
</div>
</div>This gives you full control over how your tables behave across devices. Simple wrapper, big impact.
Sometimes you need more control over how your table columns behave. That's where table-auto and table-fixed come in.
table-auto is the default. Columns size themselves based on content. Long content gets wider columns, short content gets narrower columns. It's flexible but can be unpredictable.
table-fixed gives you complete control. Columns are sized based on the width you set, and content is forced to fit. This is perfect for data tables where you want consistent column widths.
<table class='w-full table-fixed border-collapse border border-gray-300'>
<thead>
<tr class='bg-gray-800 text-white'>
<th class='w-1/4 px-4 py-3 text-left'>Task</th>
<th class='w-1/4 px-4 py-3 text-left'>Assignee</th>
<th class='w-1/6 px-4 py-3 text-left'>Status</th>
<th class='w-1/3 px-4 py-3 text-left'>Notes</th>
</tr>
</thead>
<tbody>
<tr class='border-t'>
<td class='px-4 py-2'>Update documentation</td>
<td class='px-4 py-2'>Alex Chen</td>
<td class='px-4 py-2'><span class='px-2 py-1 bg-yellow-200 text-yellow-800 rounded text-xs font-medium'>In Progress</span></td>
<td class='px-4 py-2'>Waiting for review from team lead</td>
</tr>
<tr class='border-t bg-gray-50'>
<td class='px-4 py-2'>Fix login bug</td>
<td class='px-4 py-2'>Sarah Williams</td>
<td class='px-4 py-2'><span class='px-2 py-1 bg-green-200 text-green-800 rounded text-xs font-medium'>Complete</span></td>
<td class='px-4 py-2'>Deployed to production yesterday</td>
</tr>
<tr class='border-t'>
<td class='px-4 py-2'>Design new dashboard</td>
<td class='px-4 py-2'>Mike Johnson</td>
<td class='px-4 py-2'><span class='px-2 py-1 bg-blue-200 text-blue-800 rounded text-xs font-medium'>Not Started</span></td>
<td class='px-4 py-2'>Blocked by API changes</td>
</tr>
</tbody>
</table>See how each column width is controlled with w-1/4, w-1/6, etc? No surprises, no shifting layouts.
Vertical alignment matters too. By default, table cells center their content vertically. But you can change that:
align-top pushes content to the topalign-middle keeps it centered (default)align-bottom pushes it to the bottomThis is super useful when you have cells with different amounts of content or when mixing text with images or badges.
<table class='w-full border-collapse border border-gray-300'>
<thead>
<tr class='bg-purple-600 text-white'>
<th class='px-4 py-3 text-left'>Top Aligned</th>
<th class='px-4 py-3 text-left'>Middle Aligned</th>
<th class='px-4 py-3 text-left'>Bottom Aligned</th>
</tr>
</thead>
<tbody>
<tr class='border-t'>
<td class='px-4 py-8 align-top border-r border-gray-300'>
<p class='text-sm'>This content sticks to the top of the cell</p>
</td>
<td class='px-4 py-8 align-middle border-r border-gray-300'>
<p class='text-sm'>This content stays centered vertically</p>
</td>
<td class='px-4 py-8 align-bottom'>
<p class='text-sm'>This content sinks to the bottom</p>
</td>
</tr>
</tbody>
</table>These utilities give you pixel-perfect control over your table layouts without fighting against browser defaults or writing custom CSS.
That's everything you need to style tables with Tailwind CSS. From basic borders and padding to complex responsive layouts with custom column widths and alignment.
The best part? It's all utility classes. No CSS files to maintain, no specificity wars, no mysterious layout bugs. Just clean, readable HTML that does exactly what you want.
Start with the basics – borders, padding, colors. Then add striped rows and hover effects. Make it responsive with overflow containers. And when you need precision control, reach for fixed layouts and alignment utilities.
Your tables will look better, and your users will thank you for it.
Get notified when we add new templates, components, and more!
WindyBase Make development a breezeWindyBase is a weekly curated Tailwind CSS template and tool directory built for the modern developer.
© 2026 WindyBase. All rights reserved.