<!-- NOTE: All inline styles should be removed prior to implimentation -->
<h3>Generic Table</h3>
<table summary="A Generic Table">
<caption>This is a Generic Table Caption.</caption>
<thead>
<tr>
<th scope="col">Column 1 content</th>
<th scope="col">Column 2 content</th>
<th scope="col">Column 3 content</th>
<th scope="col">Column 4 content</th>
</tr>
</thead>
<tbody>
<tr>
<td>Row 1 content</td>
<td>Row 1 content</td>
<td>Row 1 content</td>
<td>Row 1 content</td>
</tr>
<tr>
<td>Row 2 content</td>
<td>Row 2 content</td>
<td>Row 2 content</td>
<td>Row 2 content</td>
</tr>
<tr>
<td>Row 3 content</td>
<td>Row 3 content</td>
<td>Row 3 content</td>
<td>Row 3 content</td>
</tr>
<tr>
<td>Row 4 content</td>
<td>Row 4 content</td>
<td>Row 4 content</td>
<td>Row 4 content</td>
</tr>
</tbody>
</table>
<h3 style="margin-top: 50px">Generic Table with row headers</h3>
<table summary="A Generic Table with row headers">
<caption>Generic Table with row headers Caption.</caption>
<thead>
<tr>
<th scope="col">Column 1</th>
<th scope="col">Column 2</th>
<th scope="col">Column 3</th>
<th scope="col">Column 4</th>
</tr>
</thead>
<tbody>
<tr>
<th scope="row">Row 1</th>
<td>Row 1</td>
<td>Row 1</td>
<td>Row 1</td>
</tr>
<tr>
<th scope="row">Row 2</th>
<td>Row 2</td>
<td>Row 2</td>
<td>Row 2</td>
</tr>
<tr>
<th scope="row">Row 3</th>
<td>Row 3</td>
<td>Row 3</td>
<td>Row 3</td>
</tr>
<tr>
<th scope="row">Row 4</th>
<td>Row 4</td>
<td>Row 4</td>
<td>Row 4</td>
</tr>
</tbody>
</table>
<!-- NOTE: All inline styles should be removed prior to implimentation -->
<h3>Generic Table</h3>
<table summary="A Generic Table">
<caption>This is a Generic Table Caption.</caption>
<thead>
<tr>
<th scope="col">Column 1 content</th>
<th scope="col">Column 2 content</th>
<th scope="col">Column 3 content</th>
<th scope="col">Column 4 content</th>
</tr>
</thead>
<tbody>
<tr>
<td>Row 1 content</td>
<td>Row 1 content</td>
<td>Row 1 content</td>
<td>Row 1 content</td>
</tr>
<tr>
<td>Row 2 content</td>
<td>Row 2 content</td>
<td>Row 2 content</td>
<td>Row 2 content</td>
</tr>
<tr>
<td>Row 3 content</td>
<td>Row 3 content</td>
<td>Row 3 content</td>
<td>Row 3 content</td>
</tr>
<tr>
<td>Row 4 content</td>
<td>Row 4 content</td>
<td>Row 4 content</td>
<td>Row 4 content</td>
</tr>
</tbody>
</table>
<h3 style="margin-top: 50px">Generic Table with row headers</h3>
<table summary="A Generic Table with row headers">
<caption>Generic Table with row headers Caption.</caption>
<thead>
<tr>
<th scope="col">Column 1</th>
<th scope="col">Column 2</th>
<th scope="col">Column 3</th>
<th scope="col">Column 4</th>
</tr>
</thead>
<tbody>
<tr>
<th scope="row">Row 1</th>
<td>Row 1</td>
<td>Row 1</td>
<td>Row 1</td>
</tr>
<tr>
<th scope="row">Row 2</th>
<td>Row 2</td>
<td>Row 2</td>
<td>Row 2</td>
</tr>
<tr>
<th scope="row">Row 3</th>
<td>Row 3</td>
<td>Row 3</td>
<td>Row 3</td>
</tr>
<tr>
<th scope="row">Row 4</th>
<td>Row 4</td>
<td>Row 4</td>
<td>Row 4</td>
</tr>
</tbody>
</table>
/* No context defined for this component. */
$table-header-color: #e1e1e1;
$table-border-color: #a3a7aa;
table {
border: 1px solid $table-border-color;
width: 100%;
border-collapse: collapse;
border-spacing: 0;
// using @extend in case a class can't be manually attached <caption>
// `position: relative` fixes issue with table borders
caption {
@extend .u-sr-only;
position: relative;
}
tr { background-color: color(default, light); }
th { background-color: $table-header-color; }
th,
td {
border: 1px solid $table-border-color;
padding: 9px 12px;
vertical-align: top;
text-align: left;
white-space: nowrap;
&:first-child { border-left: 0; }
&:last-child { border-right: 0; }
}
thead {
tr:last-child th,
tr:last-child td { border-top: 0; }
th {
padding-top: 12px;
padding-bottom: 12px;
}
}
tbody {
tr:last-child th,
tr:last-child td { border-bottom: 0; }
tr:nth-child(odd) td { background-color: color(neutral, lightest); }
}
tfoot {
tr:last-child th,
tr:last-child td { border-bottom: 0; }
}
}
<!-- NOTE: All inline styles should be removed prior to implimentation -->
<h3>Generic Table</h3>
<table summary="A Generic Table">
<caption>Generic Table</caption>
<thead>
<tr>
<th scope="col">Column 1</th>
<th scope="col">Column 2</th>
<th scope="col">Column 3</th>
<th scope="col">Column 4</th>
</tr>
</thead>
<tbody>
<tr>
<td>Row 1</td>
<td>Row 1</td>
<td>Row 1</td>
<td>Row 1</td>
</tr>
<tr>
<td>Row 2</td>
<td>Row 2</td>
<td>Row 2</td>
<td>Row 2</td>
</tr>
<tr>
<td>Row 3</td>
<td>Row 3</td>
<td>Row 3</td>
<td>Row 3</td>
</tr>
<tr>
<td>Row 4</td>
<td>Row 4</td>
<td>Row 4</td>
<td>Row 4</td>
</tr>
</tbody>
</table>
<h3 style="margin-top: 50px">Generic Table with row headers</h3>
<table summary="A Generic Table with row headers">
<caption>Generic Table</caption>
<thead>
<tr>
<th scope="col">Column 1</th>
<th scope="col">Column 2</th>
<th scope="col">Column 3</th>
<th scope="col">Column 4</th>
</tr>
</thead>
<tbody>
<tr>
<th scope="row">Row 1</th>
<td>Row 1</td>
<td>Row 1</td>
<td>Row 1</td>
</tr>
<tr>
<th scope="row">Row 2</th>
<td>Row 2</td>
<td>Row 2</td>
<td>Row 2</td>
</tr>
<tr>
<th scope="row">Row 3</th>
<td>Row 3</td>
<td>Row 3</td>
<td>Row 3</td>
</tr>
<tr>
<th scope="row">Row 4</th>
<td>Row 4</td>
<td>Row 4</td>
<td>Row 4</td>
</tr>
</tbody>
</table>
A Generic Table that includes column headers as well as a summary attribute to describe the purpose of the data in the table. For accessibility purposes, be sure to include a caption element in each table.
caption
that is placed directly as a child of the table
element.scope="row"
should be added to the row header.A table is a static tabular structure, and as such, is not interactive. Its cells are neither focusable nor selectable.
Control + Option
←
→
↑
↓
= Navigate through table row and column content with screen reader↑
↓
arrows could cause some screen readers to skip over the caption
.When interacting with a table, screen readers should announce the following information: