TC Design
Tables
- 1 Tables vs. list views
- 2 When to use this component
- 3 When not to use this component
- 4 Best practices
- 5 Tips
- 6 Accessibility
- 6.1 1.3.1: Info and RelationshipsÂ
- 6.2 1.4.4 Resize TextÂ
- 6.3 1.4.10 ReflowÂ
- 6.3.1 Content Disappearing
- 7 Key component featuresÂ
- 7.1 PaginationÂ
- 7.2 Grid Row SelectionÂ
- 7.3 Sorting
- 8 Examples
- 9 Responsive DesignÂ
- 10 Resources
Tables vs. list views
Tables should be used for cases where users need to compare pieces of related information. In all other cases, we recommend the use of the list view component (List views). Selecting the appropriate component is important, as they have different accessibility features and behave differently on smaller browser widths.
For example, in Figure 1 you can see a table of “Most populous countries”. If each row were to be presented individually, there would not be sufficient information for the content to have meaning. In Figure 1, the population of the United States seems large, but the user does not have the full story until they see this piece of data in the larger context illustrated in Figure 2.
Most populous countries
Name | Population | Area (km2) |
---|---|---|
United States | 339,815,039 | 9.4M |
Figure 1 - Most populous countries table showing one rowÂ
Most populous countriesÂ
Name | Population | Area (km2) |
---|---|---|
India | 1,427,320,458 | 3.3M |
China | 1,425,706,656 | 9.7M |
United States | 339,815,039 | 9.4M |
Indonesia | 277,306,989 | 1.9M |
Figure 2 - Most populous countries table showing four rowsÂ
Conversely, Figure 3 illustrates an example where each row of information could be presented individually and retain meaning. In this example, a list view component should be used (List Views).
Attachments
Name | Date modified | Type |
---|---|---|
Stakeholder Presentation | 2023-05-30 | Microsoft PowerPoint Presentation |
Project Requirements | 2023-05-27 | Microsoft Word Document |
Annual Report 2022 | 2023-01-15 | PDF File |
Usage Data | 2022-12-09 | Microsoft Excel Macro |
Figure 3 - Attachments table
Helpful Questions
Try using these questions to determine the appropriate component:Â
Is the purpose of displaying this data to allow the user to compare information and gain insights?Â
Is each piece of data only meaningful when it is presented in context with other data?Â
If you answered “Yes” to the questions above, it is recommended to use a table component. If you answered “No”, it is recommended to use a list view component.Â
When to use this component
Use tables when presenting rows and columns of related information that needs to be compared
When not to use this component
Avoid using tables to make the layout of a page look a certain way - Use a layout grid instead
Avoid using tables for data that is long and wordy - Use conventional page headings and paragraphs instead
Best practices
Do
Keep tables as simple and small as possibleÂ
Order the columns to reflect the importance of the data to the userÂ
Position related columns adjacent to one anotherÂ
Left-align textual dataÂ
Right-align quantitative numbers like amounts, measures and percentages – Qualitative numbers like dates, postal codes and phone numbers can be left-alignedÂ
Consider the experience on smaller devices and, when possible, use a responsive tableÂ
Don’t
Clip, truncate or obscure cell contentÂ
Nest tables within other tables - This will make it difficult for screen readers to read the information in the table aloud in a way that makes senseÂ
Merge or split cells - Despite being standard markup for tables for many years, some screen readers still do not fully support complex tables with spanned or multiple levels of row and/or column headersÂ
Have empty table cells - Blank cells may mislead someone using a screen reader into thinking that there is nothing more in the tableÂ
Use zebra striping when the table has interactive elements as users may have a difficult time effectively differentiating between disabled, hover, focused and active statesÂ
Use an inline scroll area within the body of the table – Scroll the content on the page insteadÂ
Tips
Get users involved in determining what information needs to be displayed and how they will use itÂ
Test tables using real content in English and French – Placeholder content may not surface issues with clipping or truncation
Accessibility
The WCAG criteria outlined in this section were chosen because they represent some of the most common failures when designing and implementing these components. For a comprehensive list, please see Web Content Accessibility Guidelines (WCAG) 2.1 (w3.org).
1.3.1: Info and RelationshipsÂ
Identify Row and Column Headers
A critical step toward creating an accessible data table is to designate row and/or column headers. The scope attribute identifies whether a table header is a column header or a row header. The scope attribute tells the browser and screen reader that everything within a column that is associated to the header with scope=”col" in that column, and that a cell with scope=”row” is a header for all cells in that row.Â
All <th> elements should generally always have a scope attribute. While screen readers may correctly guess whether a header is a column header or a row header based on the table layout, assigning a scope makes this unambiguous.Â
H63: Using the scope attribute to associate header cells and data cells in data tables | WAI | W3CÂ
Associating Cells to HeadingsÂ
Relying on visual cues alone is not sufficient to create an accessible table. Tables without structural markup to differentiate and properly link between header and data cells, create accessibility barriers. Â
Proper structural markup allows people using screen readers to have the row and column headers read aloud as they navigate through the table. Screen readers speak one cell at a time and reference the associated header cells, so the reader doesn’t lose context.Â
Including CaptionsÂ
When a person accesses your website with assistive technologies, they may not be able to perceive tables visually. Data tables very often have brief descriptive text before or after the table that indicates the content of that table. This text should be associated to its respective table using the <caption> element. The <caption> element must be the first thing after the opening <table> tag.Â
While it is not necessary for each table to have a caption, a caption is generally very helpful. If present, it should be associated to the table using the <caption> element.Â
H39: Using caption elements to associate data table captions with data tables | WAI | W3CÂ
Understanding Success Criterion 1.3.1: Info and Relationships | WAI | W3CÂ
1.4.4 Resize TextÂ
The intent of this success criterion is to ensure that text can be resized without assistive technology up to 200 percent without loss of content or functionality. Users may benefit from scaling all content on the web page, but text is most critical.Â
In Microsoft Edge or Google Chrome, you can change the font size by following these steps:
Under the three dots in the top toolbar, navigate to SettingsÂ
Select AppearanceÂ
Under the Fonts section, go to Customize FontsÂ
Increase the font size by 200%Â
Understanding Success Criterion 1.4.4: Resize Text | WAI | W3CÂ
1.4.10 ReflowÂ
WCAG success criterion 1.4.10 Reflow (AA) was introduced in WCAG version 2.1 (June 2018). This criterion requires that content be presented without loss of information or functionality, and without requiring scrolling in two dimensions for:Â
Vertical scrolling content at a width equivalent to 320 CSS pixels;Â
Horizontal scrolling content at a height equivalent to 256 CSS pixels.Â
There is an exception for parts of the content which require a two-dimensional layout for usage or meaning. In the case of data tables, because the two-dimensional relationship between the headings and data cells are essential to preserve meaning, they are exempt from this success criterion. However, cells within the data table should fit within the size requirement and the content should not be clipped, truncated or obscured.
While scrolling in two dimensions is permitted as an exemption under this criterion, this may still present usability challenges on smaller viewports. Please see the Resources section for examples of responsive tables.Â
Content Disappearing
A technique that is often used to make tables more manageable on smaller browser widths is to remove columns. Reflow does not require that content be displayed in the same way on all browser widths, but it must still be available. Â
For this reason, it is not a good practice to remove data. Rather, it is recommended to design concise tables and display only the crucial data across all browser widths. This will ensure that users who may need to increase the size of the content will have an equitable experience.Â
Understanding Success Criterion 1.4.10: Reflow | WAI | W3CÂ
Key component featuresÂ
Telerik Blazor DataGrid Component - OverviewÂ
PaginationÂ
The Telerik DataGrid component for Blazor supports pagination. You can dynamically choose different Button counts, change the items per page, configure the input type, and control whether you want to show the page size dropdown to your users.Â
Blazor DataGrid Demos - Paging | Telerik UI for BlazorÂ
Grid Row SelectionÂ
The Telerik DataGrid for Blazor allows you to select an item or a multitude of items.Â
Blazor DataGrid Demos - Selection | Telerik UI for BlazorÂ
Sorting
The Telerik DataGrid for Blazor allows you to sort its data by one or multiple fields in ascending and descending order.Â
Blazor DataGrid Demos - Sorting | Telerik UI for BlazorÂ
Examples
Note: The following example is a visual illustration of how this component could be used in a MAACE application. Live examples of the Telerik UI component implemented in MAACE applications will be added when available.Â
Responsive DesignÂ
In order to be inclusive to all users, we need to consider how our applications behave on smaller viewports. (For more information on viewports, see The viewport is the window to your site – Digital.gov.) While designing and building using responsive design principles will allow you to create an optimized layout for users accessing your application on smaller viewports, this is not the only benefit. This will also ensure you are supporting users with low vision who need to enlarge text by using the browser’s zoom function.Â
When possible, it is recommended to use a responsive table. However, if users need to compare information between rows and a traditional table is needed, there are some techniques that can be used to improve the experience on smaller viewports:Â
If the table will scroll horizontally on smaller viewports, ensure that it is clearly indicated to the user that horizontal scrolling is needed so that they do not miss informationÂ
Ensure that columns and table cells are large enough to be legible – There should not be scrolling within individual table cellsÂ
Follow the recommendations listed in the Best Practices sectionÂ
Resources
Government of Canada resourcesÂ
Data tables - Canada.ca design pattern - Canada.ca
5.3 Use tables to organize data - Canada.ca Content Style Guide - Canada.caÂ
External resourcesÂ
Tables | Ontario Design SystemÂ
Table – GOV.UK Design System (design-system.service.gov.uk)Â
TC Design