Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Spanning row/column example missing required attributes #308

Open
aardrian opened this issue Nov 17, 2020 · 2 comments
Open

Spanning row/column example missing required attributes #308

aardrian opened this issue Nov 17, 2020 · 2 comments

Comments

@aardrian
Copy link

Looking at this page:
https://www.accessibility-developer-guide.com/examples/tables/spanning-rows-cols/

It shows <th>s that span but does not include the required id and headers attribute in the associated <th>s or <td>s.

Eg:

[…]
      <th colspan="2">
        Leisure Days
      </th>
    </tr>
[…]
      <th>
        Saturday
      </th>
      <th>
        Sunday
      </th>
    </tr>
[…]
      <td>
        Computer Science
      </td>
      <td>
        Chillout
      </td>
    </tr>

The content under the heading "Tricky screen reader navigation" makes assertions about how screen readers read this table, but those assertions are based on an invalid pattern.

Correct code might look like this:

[…]
      <th colspan="2" id="Leisure">
        Leisure Days
      </th>
    </tr>
[…]
      <th id="Sat" headers="Leisure">
        Saturday
      </th>
      <th id="Sun" headers="Leisure">
        Sunday
      </th>
    </tr>
[…]
      <td headers="Leisure Sat">
        Computer Science
      </td>
      <td headers="Leisure Sun">
        Chillout
      </td>
    </tr>

I have an example here:
https://adrianroselli.com/2017/11/hey-its-still-ok-to-use-tables.html#WCAGSpanning

Which is based on this WCAG example:
https://www.w3.org/TR/WCAG20-TECHS/H43.html

@backflip backflip self-assigned this Mar 22, 2021
@renestalder renestalder added this to To-do / in progress in Overall Issue Dashboard Jun 27, 2021
@jmuheim
Copy link
Collaborator

jmuheim commented Feb 1, 2023

I never understood what the headers attribute is useful for in simple tables: the association between th and td is always given automatically, and I never experienced any issues with screen readers. As soon as tables get more complicated and therefore a headers attribute seems necessary, I usually discourage to create tables with such messy data anyway.

Or do I misunderstand something here?

@backflip backflip removed their assignment Feb 1, 2023
@aardrian
Copy link
Author

@jmuheim The headers attribute has no purpose in simple tables. It does have purpose in tables with spanning cells. However, the headers attribute has a stack of issues: https://adrianroselli.com/2022/01/accessible-cart-tables.html

As such, tables should generally avoid spanning cells when possible: https://adrianroselli.com/2023/02/avoid-spanning-table-headers.html

Sadly, those browser bugs I link are less likely to be fixed if people are not using the correct pattern.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: Testing ZFA
Development

No branches or pull requests

3 participants