Content
Table
Tables for data people need to compare, such as fees or opening hours.
When to use
- For data with rows and columns that people compare: fees, opening hours, deadlines.
When not to use
- For page layout.
- For a single list of things. Use a list.
- For data with many columns that people mostly read on phones, unless it is stacked (below). Otherwise split it into smaller tables, or offer it as a download.
How to use
- Give every table a caption (
ggds-table__caption) saying what it shows and when: "Licence fees, 2026". - Use
<th scope="col">for column titles, and<th scope="row">for the first cell of a row when it names the row. - Right-align numbers with
ggds-table__numeric, on the numbers and on their column title. Digits line up, so amounts are easy to compare. - Put units in the column title, "Fee (GH₵)", not in every cell. Use the same number of decimal places down a column.
- Do not leave cells empty. Write "None" or "Not applicable".
- On pages people mostly read on phones, add
ggds-table--stack. On a narrow screen each row becomes a card, with each cell under its column's name, so nothing is squeezed and nobody scrolls sideways. Give the row's name a<th scope="row">: it becomes the card's title. - Avoid merged cells. They are hard to follow with a screen reader.
- Wrap the table in
ggds-table-wrapwithrole="region",tabindex="0"andaria-labelledbypointing at the caption'sid.
Do
- Keep column titles short.
- Put the most important column first.
Don't
- Use a table to place things side by side.
- Use an image of a table.
Accessibility
What GGDS does
- Wide tables scroll inside their box, so the page does not scroll sideways at 320px (WCAG 1.4.10).
- The box shows the gold focus ring when it has keyboard focus.
- A stacked table keeps its table roles, row titles and column names for screen readers (@ggds/js sets them, as changing how a table is drawn can remove them).
- The header row has a thicker line under it, and numbers use figures of equal width.
What you need to do
- Give every table a
<caption>, and use<th>withscopefor titles (WCAG 1.3.1). - Give the wrapper
role="region",tabindex="0"andaria-labelledby, so keyboard users can scroll it and screen readers name it. - Use tables for data, never for layout.
Example: Data table
<div class="ggds-table-wrap" role="region" aria-labelledby="fees-caption" tabindex="0">
<table class="ggds-table">
<caption class="ggds-table__caption" id="fees-caption">Licence fees, 2026</caption>
<thead>
<tr>
<th scope="col">Licence</th>
<th scope="col">Duration</th>
<th scope="col" class="ggds-table__numeric">Fee (GH₵)</th>
</tr>
</thead>
<tbody>
<tr><th scope="row">Internet service provider</th><td>5 years</td><td class="ggds-table__numeric">12,000</td></tr>
<tr><th scope="row">Community radio</th><td>3 years</td><td class="ggds-table__numeric">1,500</td></tr>
<tr><th scope="row">Courier service</th><td>1 year</td><td class="ggds-table__numeric">2,400</td></tr>
</tbody>
</table>
</div>
<p class="ggds-hint">Example figures only.</p><>
<div className="ggds-table-wrap" role="region" aria-labelledby="fees-caption" tabIndex={0}>
<table className="ggds-table">
<caption className="ggds-table__caption" id="fees-caption">Licence fees, 2026</caption>
<thead>
<tr>
<th scope="col">Licence</th>
<th scope="col">Duration</th>
<th scope="col" className="ggds-table__numeric">Fee (GH₵)</th>
</tr>
</thead>
<tbody>
<tr><th scope="row">Internet service provider</th><td>5 years</td><td className="ggds-table__numeric">12,000</td></tr>
<tr><th scope="row">Community radio</th><td>3 years</td><td className="ggds-table__numeric">1,500</td></tr>
<tr><th scope="row">Courier service</th><td>1 year</td><td className="ggds-table__numeric">2,400</td></tr>
</tbody>
</table>
</div>
<p className="ggds-hint">Example figures only.</p>
</>Example: Stacked on phones
<div class="ggds-table-wrap" role="region" aria-labelledby="offices-caption" tabindex="0">
<table class="ggds-table ggds-table--stack">
<caption class="ggds-table__caption" id="offices-caption">Regional offices: opening hours</caption>
<thead>
<tr>
<th scope="col">Office</th>
<th scope="col">Address</th>
<th scope="col">Open</th>
<th scope="col">Phone</th>
</tr>
</thead>
<tbody>
<tr><th scope="row">Greater Accra</th><td>Ministries, Accra</td><td>Monday to Friday, 8am to 5pm</td><td>030 000 0001</td></tr>
<tr><th scope="row">Ashanti</th><td>Adum, Kumasi</td><td>Monday to Friday, 8am to 4:30pm</td><td>032 000 0002</td></tr>
<tr><th scope="row">Northern</th><td>Central Business District, Tamale</td><td>Monday to Friday, 8am to 4pm</td><td>037 000 0003</td></tr>
</tbody>
</table>
</div>
<p class="ggds-hint">Example details only. On a phone each office is a card; on a wider screen it is a table.</p><>
<div className="ggds-table-wrap" role="region" aria-labelledby="offices-caption" tabIndex={0}>
<table className="ggds-table ggds-table--stack">
<caption className="ggds-table__caption" id="offices-caption">Regional offices: opening hours</caption>
<thead>
<tr>
<th scope="col">Office</th>
<th scope="col">Address</th>
<th scope="col">Open</th>
<th scope="col">Phone</th>
</tr>
</thead>
<tbody>
<tr><th scope="row">Greater Accra</th><td>Ministries, Accra</td><td>Monday to Friday, 8am to 5pm</td><td>030 000 0001</td></tr>
<tr><th scope="row">Ashanti</th><td>Adum, Kumasi</td><td>Monday to Friday, 8am to 4:30pm</td><td>032 000 0002</td></tr>
<tr><th scope="row">Northern</th><td>Central Business District, Tamale</td><td>Monday to Friday, 8am to 4pm</td><td>037 000 0003</td></tr>
</tbody>
</table>
</div>
<p className="ggds-hint">Example details only. On a phone each office is a card; on a wider screen it is a table.</p>
</>Use it
- Stylesheet
ggds.cssincludes it. To load only the parts you use:core.css, thencomponents/table.css(0.6 KB with gzip, minified).- JavaScript
- Optional, for ggds-table--stack: @ggds/js names each cell after its column and keeps the table roles for screen readers. Without it, the table stays a table that scrolls sideways.
HTML
Copy the HTML under each example above. It works in any website.
Astro
No Astro component: copy the HTML.
React and Next.js
No React component: switch the HTML under an example to JSX (React) and copy it.
Django
No template tag: copy the HTML into your template.
Classes and states
| Class | What it does |
|---|---|
.ggds-table-wrap | A box that scrolls a wide table sideways. Give it role="region", tabindex="0" and aria-labelledby. |
.ggds-table | The table. |
.ggds-table__caption | The caption: what the table shows. |
.ggds-table__numeric | Right-aligns a column of numbers. |
.ggds-table--stack | On a narrow screen, each row becomes a card with every cell under its column's name, so people read down instead of sideways. Needs @ggds/js. |
Accessibility tests
Automated, on every change
These run each time GGDS changes. A change that fails one is not accepted.
- WCAG 2.2 A and AA rules (axe), at desktop and phone widths, on every example
- No sideways scrolling on a 320px screen, also with a wide font, on every example
- Every approved colour pair meets its contrast minimum, for every institution theme
- No inline scripts or styles, so it runs under a strict Content Security Policy
By people, with assistive technology
Automated tests find only some of the barriers people meet. These checks are still to be done.
| Check | Result | Notes |
|---|---|---|
| Keyboard only | Not tested yet | Waiting for the external audit with disabled people (decision D-09). |
| NVDA screen reader with Firefox or Chrome (Windows) | Not tested yet | Waiting for the external audit with disabled people (decision D-09). |
| JAWS screen reader with Chrome (Windows) | Not tested yet | Waiting for the external audit with disabled people (decision D-09). |
| VoiceOver screen reader with Safari (iPhone) | Not tested yet | Waiting for the external audit with disabled people (decision D-09). |
| TalkBack screen reader with Chrome (Android) | Not tested yet | Waiting for the external audit with disabled people (decision D-09). |
| Zoom to 400%, and increased text spacing | Not tested yet | Waiting for the external audit with disabled people (decision D-09). |
| Windows contrast themes (forced colours) | Not tested yet | Waiting for the external audit with disabled people (decision D-09). |
| Voice control (Voice Access or Dragon) | Not tested yet | Waiting for the external audit with disabled people (decision D-09). |
Changes
| Version | Change |
|---|---|
| 0.3.0 | Table: hidden text for screen readers in a cell (such as “, EX-PA-T-2026-031” after a link) no longer makes a narrow page scroll sideways. |
| 0.2.0 | Fuller guidance for tags, breadcrumbs, disclosures, the skip link, pagination, rich text, tables and tab links. |
| 0.1.0 | Added. |
Related components
Something wrong, unclear or missing? or suggest a change to it on GitHub. You need a GitHub account.