Accessible Data Table
Creates an accessible data table with proper scope attributes, captions, column groups, and responsive design for tabular data presentation.
Code
<table>
<caption>
Employee Directory - Q1 2025
</caption>
<colgroup>
<col class="name-col">
<col class="dept-col">
<col class="role-col">
<col class="salary-col">
</colgroup>
<thead>
<tr>
<th scope="col">Name</th>
<th scope="col">Department</th>
<th scope="col">Role</th>
<th scope="col" class="numeric">Salary</th>
</tr>
</thead>
<tbody>
<tr>
<th scope="row">Alice Johnson</th>
<td>Engineering</td>
<td>Senior Developer</td>
<td class="numeric">$95,000</td>
</tr>
<tr>
<th scope="row">Bob Smith</th>
<td>Marketing</td>
<td>Manager</td>
<td class="numeric">$85,000</td>
</tr>
<tr>
<th scope="row">Carol Davis</th>
<td>Engineering</td>
<td>Team Lead</td>
<td class="numeric">$110,000</td>
</tr>
</tbody>
<tfoot>
<tr>
<th scope="row" colspan="3">Average Salary</th>
<td class="numeric">$96,667</td>
</tr>
</tfoot>
</table>
<style>
table { border-collapse: collapse; width: 100%; }
th, td { padding: 0.75rem; text-align: left; border-bottom: 1px solid #ddd; }
.numeric { text-align: right; }
caption { font-weight: bold; margin-bottom: 0.5rem; }
</style>Accessible tables use <caption> for description, scope="col"/scope="row" to associate headers with cells, <thead>/<tbody>/<tfoot> for structure, and <colgroup> for column styling. <th> for row headers improves screen reader navigation. Keep tables for tabular data only, not layout. For responsive tables, consider horizontal scroll or card transformation.
Interactive Tools for This Topic
WCAG Color Contrast CheckerCalculate WCAG 2.1 color contrast ratios between foreground and background colors. Verify AA and AAA compliance levels for normal and large text accessibility.Tailwind Color Palette GeneratorGenerate a balanced 50-950 Tailwind CSS custom property color scale from any hex, RGB, or HSL base color with WCAG 2.1 contrast ratios for every stop.CSS Color Name LookupTranslate between CSS keyword color names and hex values with RGB and HSL conversions, exact name matching, and nearest-color suggestions.CSS Color ConverterConvert colors between HEX, rgb(), and hsl() instantly, with support for shorthand hex and rgb or hsl inputs. Fully offline and dependency free.
Report a problem with this exampleOpens a pre-filled issue on GitHub.