Skip to content

kable(): accessibility scope attributes in HTML tables (#1747) - #2500

Merged
yihui merged 1 commit into
masterfrom
feat/kable-html-accessibility
Sep 19, 2026
Merged

yihui merged 1 commit into
masterfrom
feat/kable-html-accessibility

Conversation

@yihui

@yihui yihui commented Sep 19, 2026

Copy link
Copy Markdown
Owner

Closes #1747

Adds accessibility markup to the HTML tables generated by kable(), per the WAI tables tutorial.

  • scope="col" on column headers — emitted unconditionally. It lets screen readers associate each data cell with its column header, and does not change how the table renders.
  • <th scope="row"> on row-name cells — opt-in via options(knitr.table.html.row.header = TRUE). When on, the first column (the row names) is marked up as row headers instead of <td>. Kept off by default because <th> may be styled differently from <td> (e.g., bold) and could affect existing CSS, so this does not silently change anyone's current output.

The empty corner cell above the row names is a header for neither dimension, so it gets no scope.

Snapshot tests in test-table.md cover both the default (scope="col" only) and the opt-in (<th scope="row">) output.

🤖 Generated with Claude Code

Column headers in HTML tables now carry scope="col" so screen readers can
associate data cells with their column headers. This is emitted unconditionally
and does not change how tables render.

Row-name cells can optionally be marked up as row headers (<th scope="row">
instead of <td>) by setting options(knitr.table.html.row.header = TRUE). This
is off by default because <th> cells may be styled differently from <td> (e.g.,
bold) and could affect existing CSS. The empty corner cell above the row names
is not a header for either dimension, so it receives no scope.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

feature request: more accessibility/navigation tags in kable_html

1 participant