Skip to content

Improve table markup for accessibility (a11y issue) #1025

@batpigandme

Description

@batpigandme

Use scope = "col" for all column headers denoted with <th> tags

This is, in effect, the same as the gt issue #680, opened by @jooyoungseo. This is currently missing from all of the tables I've generated based on the Quarto docs (e.g. markdown, knitr::kable(), DT, Python tabulate, etc.).

WCAG resources: H63: Using the scope attribute to associate header cells and data cells in data tables

Use <th scope="row"> for all row names

See @jooyoungseo's gt issue #678 for accessibility implications. In addition to gt, this applies to the default output for knitr::kable() and DT::datatable(), which include row names. Note also that the empty cell above the row names should be an empty <td></td> (as opposed to empty <th></th>, as it is now).

Let me know if you think it would be better to open this issue directly in knitr and DT.

WCAG resources: See H63 (above), and W3C WAI's Tables with Two Headers.

Support multi-level and/or irregular headers?

I think this is currently out of scope for Quarto itself, as (thus far) I've only been able to generate such tables by using gt, kableExtra, and DT with a custom table container.

The easier of the two would be Tables with Irregular Headers, which uses arguments to <th> (e.g. <th colspan="2" scope="colgroup"> for two columns, or <th rowspan="2" scope="rowgroup"> for two rows).

For Tables with Multi-Level Headers, such as those generated in gt and with kabelExtra, headers get ids, and are then associated with lower <th>, and <td> elements using headers="foo bar baz".

Watch related issue #926 for gt for @rich-iannone's forthcoming implementation.

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions