Repository navigation
kable(): accessibility scope attributes in HTML tables (#1747) - #2500
Merged
Merged
Conversation
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>
This was referenced Sep 19, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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 viaoptions(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.mdcover both the default (scope="col"only) and the opt-in (<th scope="row">) output.🤖 Generated with Claude Code