I am currently working on a webpage where I need to implement a table with a header row that can be toggled between visible and hidden based on user configuration. The challenge is to ensure full accessibility for this table, especially in terms of navigation shortcuts that read the row/column headers efficiently. Although I primarily test using ChromeVox, I plan to explore behaviors with other screen readers as well.
The structure of my layout resembles the following:
CSS:
.table-header-show {
}
.table-header-hide {
display: none;
}
HTML:
<table>
<!-- ${show} determines which class to apply based on user settings -->
<thead class="table-header-${show}">
<tr>
<th>Name</th>
<th>Value 1</th>
<th>Value 2</th>
</tr>
</thead>
<tbody>
<tr>
<td>John Doe</td>
<td>Value 1a</td>
<td>Value 2a</td>
</tr>
</tbody>
</table>
While the visibility of the header poses no issues when not hidden, there are challenges with its behavior when it's hidden. Different screen readers handle this differently:
- I aim to have the header row skipped during regular navigation* while utilizing it to announce column labels
- ChromeVox successfully skips the header during navigation but fails to use it for labeling columns
- Moving the hiding functionality from a CSS class to a
style
attribute resolves both desired behaviors in ChromeVox - There is uncertainty about relying solely on
display: none
for hiding content, as it may or may not be ignored by screen readers depending on the situation
Given these challenges, how can I achieve consistent behavior across browsers and screen readers?
- Some suggest off-screen/1px-sized hiding to maintain accessibility without having all column headers announced simultaneously,