Components

Table

Use the table component to make information easier to compare and scan for users.

When to use this component

Use the table component to let users compare information in rows and columns.

When not to use this component

Never use the table component to layout content on a page. Instead, use the grid system.

How it works

Table captions

Use the <caption> element to describe a table in the same way you would use a heading. A caption helps users find, navigate and understand tables.

There are other styling options for table captions. You can use govuk-table__caption--s, govuk-table__caption--m, govuk-table__caption--l and govuk-table__caption--xl classes to make them larger or smaller from the default.

Table headers

Use table headers to tell users what the rows and columns represent. Use the scope attribute to help users of assistive technology distinguish between row and column headers.

There are 2 ways to use the table component. You can use HTML or, if you are using Nunjucks or the GOV.UK Prototype Kit, you can use the Nunjucks macro.

Numbers in a table

When comparing columns of numbers, align the numbers to the right in table cells.

Custom column widths

You can use the width override classes to set the width of table columns.

If the width override classes do not meet your needs you can create your own width classes and apply them to the cells in the table head. These can be added using the classes option in the Nunjucks macro or adding the class directly to the individual cells within govuk-table__head as below.

To learn more about this, read guidance on extending and modifying components in production.

Tables with a lot of data

If possible, you should aim to have less data in your tables. If you have a lot of data, try to organise it into multiple tables or multiple pages.

If you cannot split your data, you can use the CSS class govuk-table--small-text-until-tablet. This class reduces the size of the text on small screens so large amounts of data has more empty space around it. This makes it easier to visually differentiate between each piece of data when read on small screens.

The CSS class govuk-table--small-text-until-tablet is only available in version 5.2 of GOV.UK Frontend and later.

Read about updating your service to use the new type scale.

You should not use this class on tables unless your table has a lot of data, because a smaller amount of data is easier to read if the text is larger.

Help improve this component

To help make sure that this page is useful, relevant and up to date, you can:

Tell us if your service uses this component

Take part in our usage survey (opens in a new tab) to help us improve this component to better meet the needs of the services that use it.

Need help?

If you’ve got a question about the GOV.UK Design System, contact the team.