<?xml version="1.0" encoding="utf-8"?>

Tables serve as powerful tools for displaying complex data relationships but present significant barriers when inaccessible. Proper table structure requires clear headers, appropriate markup, and logical organization to ensure all users can navigate and comprehend tabular information. Screen readers rely on correctly implemented HTML semantics to announce relationships between data cells and their corresponding headers.

Beyond basic markup, accessible tables benefit from features like captions, summaries, and proper scope attributes that provide crucial context. Well-designed tables maintain simplicity through strategic column management, responsive layouts, and appropriate visual styling that enhances rather than hinders comprehension. These practices don't merely accommodate users with disabilities; they improve usability for everyone navigating complex information structures across diverse devices and contexts.

Exercise #1

Use the <table> element for tabular data

Use the <table> element for tabular data Bad Practice
Use the <table> element for tabular data Best Practice

Tables on the web serve two distinct purposes: displaying data and creating layouts. Data tables organize complex information with clear row and column headers. Layout tables arrange page elements without logical headers.

Assistive technologies interact differently with each table type, making proper implementation essential. For layouts, CSS is now the recommended approach since screen readers process content in the order it appears in the code. For data tables, the HTML <table> element is required.

The <table> element enables screen readers to announce crucial information like the table's dimensions, provide specialized navigation controls, and correctly associate data cells with their headers. This structured markup creates a meaningful experience for users relying on assistive technology.

Exercise #2

Use the <caption> element for the table title

Use the <caption> element for the table title Bad Practice
Use the <caption> element for the table title Best Practice

A caption is similar to a heading for a table that screen readers read out. It helps users identify a table, understand what it's about and decide if they want to read it. While every table may not need a caption, they are generally beneficial. Use the <caption> element right after the opening <table> tag to associate the caption with the respective table.

For more complex tables, consider adding a summary for assistive technology users, including the information stating how the data in the table is organized. You can read about the different ways to add a summary on The World Wide Web Consortium website.[1]

Exercise #3

Don't leave table headers empty

Don't leave table headers empty Bad Practice
Don't leave table headers empty Best Practice

Data tables effectively organize complex information in a structured format. While simple tables without headers may seem clear to visual users, they create significant barriers for those using assistive technologies who rely on these headers for context.

To ensure accessibility, always include text in every table header cell. This includes the often-overlooked top-left cell that may appear unnecessary in visual layouts but provides crucial orientation information for screen reader users.

Headers establish relationships between data cells and create a framework that helps users understand how information connects. Without proper headers, assistive technology users cannot determine what values relate to which categories, making the data effectively unusable.

Pro Tip: If your table has cells without data, mark them with 0, NA, or "blank" instead of leaving them empty.

Exercise #4

Use the <th> element for table headers

Use the <th> element for table headers

Correct markup is key to making your tables accessible. Mark header cells with <th> and data cells with <td> tags. The relationship between the headers and data cells quickly becomes ambiguous in tables with both row and column headers or larger tables with complex data. Define each header's direction by setting the scope attribute to col or row for columns and rows, respectively.

Correct markup adds context for every data cell, giving assistive technology users the same obvious information for visual users. As they move through the table, the screen reader announces column headings when moving left and right and rows headings when moving up and down. For example, when a user in the "Event" column moves one cell down, they'll hear "May 14, Classical Music," learning that on May 14, there will be a classical music concert.

Exercise #5

Use simple tables

Use simple tables Bad Practice
Use simple tables Best Practice

Many screen readers still struggle with complex tables containing merged cells or multiple header levels. These assistive technologies may announce cell relationships incorrectly or fail to maintain proper orientation within complicated structures.

Even when screen readers technically support complex tables, non-visual users face significant cognitive load trying to mentally map and retain relationships between scattered data points. Simpler table structures with clearly defined rows, columns, and single-level headers allow all users to navigate and comprehend information more efficiently, regardless of how they access content.

Pro Tip: When complex data relationships can't be avoided, consider breaking information into multiple simple tables with clear relationships rather than creating one complex table with merged cells.

Exercise #6

Use proportional cell width

Use proportional cell width Bad Practice
Use proportional cell width Best Practice

Normally, web browsers automatically determine the table's width and set the rows and columns' dimensions. If you want to have more control, you also have an option to set the width of your table cells manually. In this case, avoid using absolute values in pixels and go for percentages (%), so browsers can automatically adjust the table width and reduce horizontal scrolling.

When it comes to cell height, avoid setting it manually so that cells can expand to accommodate their content. It's especially important for users with low vision that may enlarge text content.

Exercise #8

Unordered lists

Unordered lists

The HTML <ul> element creates unordered lists that display information without numerical sequence. This container element wraps individual list items, each marked with the <li> tag.

Browsers render unordered lists with bullet points by default, though this styling can be modified with CSS. While items lack explicit numbering, they appear in the same sequence as written in the code, maintaining their relative order.

Unordered lists excel at presenting collections where sequence doesn't matter, such as shopping lists or feature sets. They provide clear visual separation between items and create proper semantic structure that assistive technologies can interpret correctly.

Pro Tip: Use unordered lists to improve content scanability, but avoid nesting them more than 3 levels deep, as excessive nesting reduces readability for all users.

Exercise #9

Ordered lists

Ordered lists

The HTML <ol> element creates ordered lists that display information in a specific sequence. Like unordered lists, this container wraps individual <li> elements that represent each list item.

Browsers automatically number ordered list items sequentially, eliminating the need to manually maintain numbering when adding or removing items. The type attribute allows customization of numbering styles (numbers, letters, or Roman numerals), while the reversed attribute creates countdown sequences.

Ordered lists are ideal for step-by-step instructions, recipes, rankings, or any content where sequence matters. They provide both visual and semantic structure that communicates importance of order to all users, including those using assistive technologies.

Exercise #10

Description lists

Description lists

Description lists provide a structured way to present term-definition pairs using specialized HTML elements. The <dl> element serves as the container for the entire description list.

Within description lists, two distinct elements work together to create meaningful relationships. The <dt> (definition term) element marks terms being defined, while the <dd> (definition description) element contains the explanation or definition of each term. Each term can have multiple descriptions if needed.

This semantic structure is particularly valuable for glossaries, dictionaries, FAQs, and metadata presentations. Screen readers announce these relationships specifically, helping users understand the connection between terms and their definitions without relying on visual formatting.

Complete this lesson and move one step closer to your course certificate