Tables
Users need to see structured data in a manner that makes the data readable, scannable, and comparable.
Accessibility
A <caption>
should be used to describe the table content. While it is not necessary for each table to have one, it is generally very helpful. If you want to hide this from users, please use the class .is-sr-only
.
Identify row and column headers using <th>
for table header cells and <td>
for table data cells.
Use the scope
attribute to associate data cells with the appropriate headers. This identifies whether a <th>
is a column or row header.
Usage
- table attributes such as cellspacing, cellpadding or border should not be used
- use
<thead>
and<tbody>
to group table headings and data - do not add a width to size cells, let them resize to the device size, if you really need to add widths, use percentages
- use a caption to indicate the content of that table
- when comparing rows of numbers, align numbers to the right in table cells
- no need for paragraphs unless you need to, use nowrap sparingly
- You can combine any or all five modifiers:
table is-bordered
is-striped
is-narrow
is-hoverable
andis-fullwidth
Element / Class name | Description |
---|---|
table | The main container |
caption | The table caption element specifies the caption (or title) of a table and if used is always the first child of a <table> |
thead | The optional top part of the table |
tbody | The content part of the table |
tfoot | The optional bottom part of the table |
tr | A table row |
th | A table cell heading |
td | A table cell |