Tables present data in a structured format for users to scan and
compare.
Guidance
Tables display data in a tabular format that is easy for users to scan. We wrap tables in a container so
complex data will be horizontally scrollable within the table area without breaking the entire page on
mobile screens.
You can use helper classes to modify the alignment of data in your table by placing the following
classes on the td or th element:
Number: Add .number to right align numerical data.
Right: Add .right to right align content.
Center: Add .center to center align content.
Guidelines for using tables:
Do
Use the <th> element to create table headers. Headers should be used to
label columns or rows.
Use the scope attribute to specify whether a header cell applies to a
column or row.
For tables with complex information, consider using the <caption> element
to provide a description for screen reader users.
Don’t
Use a table for layout purposes.
Do not use tables to create an editable interface.
Do not put form fields inside a table.
Use a table if you don’t have tabular data.
Table
Table description that is visually hidden but will be read out loud by
screen readers.
Header
Header
Header
Cell
Cell
Cell
Cell
Cell
Cell
Cell
Cell
Cell
HTML
<divclass="gnb-table-container"><captionclass="sr-only">Table description that will be read out loud by screen readers.</caption><tableclass="gnb-table"><thead><tr><thscope="col">Header</th><thscope="col">Header</th><thscope="col">Header</th></tr></thead><tbody><tr><td>Cell</td><td>Cell</td><td>Cell</td></tr><tr><td>Cell</td><td>Cell</td><td>Cell</td></tr><tr><td>Cell</td><td>Cell</td><td>Cell</td></tr></tbody></table></div>
Table with a minimum width
For some data, you might want to ensure that your table doesn't get squished too much on smaller
screens. To control this, you can add an inline style on the <table> to set a minimum
width.
Table description that is visually hidden but will be read out loud by
screen readers.
Header
Header
Header
Cell
Cell
Cell
Cell
Cell
Cell
Cell
Cell
Cell
HTML
<divclass="gnb-table-container"><tableclass="gnb-table"style="min-width: 800px;"><captionclass="sr-only">Table description that will be read out loud by screen readers.</caption><tableclass="gnb-table"><thead><tr><thscope="col">Header</th><thscope="col">Header</th><thscope="col">Header</th></tr></thead><tbody><tr><td>Cell</td><td>Cell</td><td>Cell</td></tr><tr><td>Cell</td><td>Cell</td><td>Cell</td></tr><tr><td>Cell</td><td>Cell</td><td>Cell</td></tr></tbody></table></div>
Table with a column that has a minimum width
You can also use an inline style on a <td> to control the width of a specific
column.
Table description that is visually hidden but will be read out loud by
screen readers.
Column with a min-width applied
Header
Header
Cell
Cell
Cell
Cell
Cell
Cell
Cell
Cell
Cell
HTML
<divclass="gnb-table-container"><tableclass="gnb-table"><captionclass="sr-only">Table description that will be read out loud by screen readers.</caption><tableclass="gnb-table"><thead><tr><thscope="col"style="min-width: 200px;">Column with a min-width applied</th><thscope="col">Header</th><thscope="col">Header</th></tr></thead><tbody><tr><td>Cell</td><td>Cell</td><td>Cell</td></tr><tr><td>Cell</td><td>Cell</td><td>Cell</td></tr><tr><td>Cell</td><td>Cell</td><td>Cell</td></tr></tbody></table></div>