WebAIM - Web Accessibility In Mind

E-mail List Archives

using role="columnheader" instead of <th>

for

From: glen walker
Date: Oct 26, 2021 7:33PM


Technically you can make a fully accessible table without using semantic
table elements provided you specify all the appropriate roles.

I have a situation where <table> elements *are* being used but the
structure of the code can't be changed (the element types can't change) but
attributes can be added. In order to add row and column headers to the
table, we are adding role="columnheader" or role="rowheader" on existing
<td> elements.

Now, ignoring the second rule of ARIA (
https://www.w3.org/TR/aria-in-html/#second), although it says "unless you
really have to", do you see any problem with having <td
role="columnheader">? It looks weird but in theory it should behave like a
<th scope="col">. Testing I've done with it seems to work. I didn't
expect it *not* to work but it just looks and feels weird.