border-collapse
Controls whether adjacent cell borders merge.
Learn Table Borders with practical examples for tables, lists, structured data relationships, accessibility, SEO and live practice.
HTML data structures
Borders make a table easier to scan when they separate rows, columns or groups. But borders are visual CSS, not the meaning of the table.
Old HTML attributes such as border, cellpadding and cellspacing still appear in old examples, but modern projects should style tables with CSS.
A professional table uses borders to guide the eye without making the interface noisy.
Controls whether adjacent cell borders merge.
Controls space between separated table cells.
Often cleaner than full boxed grids.
Borders should be visible without overpowering the data.
Syntax and structure
HTML keeps the data meaningful. CSS decides whether the table uses full borders, row dividers or soft card-like rows.
<table class="data-table"> <caption>Recent invoices</caption> <tr><th scope="col">Invoice</th><th scope="col">Status</th></tr> <tr><td>2026-001</td><td>Paid</td></tr> </table> <style> .data-table { border-collapse: collapse; } .data-table th, .data-table td { border-bottom: 1px solid #d8dde8; padding: 12px 14px; } </style>
<table border="1" cellpadding="12" cellspacing="0"> <tr><td><b>Invoice</b></td><td><b>Status</b></td></tr> <tr><td>2026-001</td><td>Paid</td></tr> </table>
HTML quick reference
Use these patterns when you need the syntax quickly. Each example has its own anchor, so search engines and readers can land directly on the exact pattern instead of only at the top of the lesson.
A clean version of the markup from this lesson. Use it when you need the correct HTML shape quickly.
<table class="data-table"> <caption>Recent invoices</caption> <tr><th scope="col">Invoice</th><th scope="col">Status</th></tr> <tr><td>2026-001</td><td>Paid</td></tr> </table> <style> .data-table { border-collapse: collapse; } .data-table th, .data-table td { border-bottom: 1px solid #d8dde8; padding: 12px 14px; } </style>
Meaningful markup that stays understandable before CSS and JavaScript are added.
The starting point from the practice lab. Change the HTML first, then use CSS only for presentation.
<main class="demo-card"> <table class="data-table"> <caption>Invoices</caption> <tr><th scope="col">Number</th><th scope="col">Status</th><th scope="col">Amount</th></tr> <tr><td>2026-001</td><td>Paid</td><td>EUR 240</td></tr> <tr><td>2026-002</td><td>Open</td><td>EUR 180</td></tr> </table> </main> <style> body { margin: 0; min-height: 100vh; display: grid; place-items: center; font-family: Inter, system-ui, sans-serif; background: #07111f; color: white; } .demo-card { width: min(820px, calc(100% - 32px)); padding: 34px; border-radius: 24px; background: #101a2d; box-shadow: 0 30px 80px rgba(0, 0, 0, 0.3); } h1 { margin: 0 0 18px; font-size: clamp(32px, 6vw, 54px); line-height: 1; } table { width: 100%; border-collapse: collapse; color: #f7f7f4; } caption { caption-side: top; margin-bottom: 12px; color: #8cffc1; font-weight: 900; text-align: left; } th, td { border-bottom: 1px solid rgba(255, 255, 255, 0.14); padding: 13px 14px; text-align: left; vertical-align: top; } th { color: #8cffc1; font-weight: 900; } ul, ol { display: grid; gap: 10px; margin: 0; padding-left: 24px; color: #cfd8e6; } li::marker { color: #8cffc1; font-weight: 900; } dl { margin: 0; } </style>
A complete practice snippet that shows how the HTML behaves in context.
A weak pattern from the lesson. Use it as a warning sign when reviewing real pages.
<table border="1" cellpadding="12" cellspacing="0"> <tr><td><b>Invoice</b></td><td><b>Status</b></td></tr> <tr><td>2026-001</td><td>Paid</td></tr> </table>
A recognizable mistake you can search for and refactor.
Rules that matter
Tables and lists are small elements with big structural value. They help users scan, compare, follow steps and understand how pieces of information belong together.
Use CSS instead of border, cellpadding, cellspacing or bgcolor attributes.
Full grids, row dividers and card rows each create a different feeling.
Borders without padding make tables feel cramped.
Headers, totals and group rows can use stronger lines than normal rows.
Border contrast changes quickly across backgrounds.
A border can make something look like a table, but only table markup makes it table data.
Production thinking
This matters because table styling should help people read faster. A table with noisy borders can be technically correct but visually exhausting.
Borders do not create meaning for assistive technology. The semantic table structure still has to be correct.
Use reusable table classes so every data table in a project feels consistent. Random border styles quickly make dashboards look messy.
Borders do not directly affect SEO, but readable data tables can improve engagement and clarity for comparison content.
Live code lab
Edit the HTML or CSS, then use Run to refresh the preview. The preview is isolated, so links and forms stay inside this practice area.
Mini assignment
Practice assignment
Try it yourself
Self-check
Do not only read this page. Answer these questions out loud or write the answers in your own notes. If one answer feels vague, revisit the examples before moving on.