Skip to content

[Rule RSRCH]: Request for new rule: table_caption_exists #2373

@mbusch3

Description

@mbusch3

Rule description

The current ruleset has a few existing checks to make sure that every <table> has an appropriate <caption> describing its content:

  • table_caption_nested makes sure that any <caption> tags are nested properly inside the <table> tags.
  • table_caption_empty makes sure that when a <caption> tag is present, it contains text.

However, when tables don't contain captions at all, there is no issue reported. Based on the definition of WCAG 1.3.1: Info and Relationships, and specifically Technique H39: Using caption elements to associate data table captions with data tables, every data table really, really should contain a caption.

I suggest we add a rule for table_caption_exists to verify that data tables have their required captions.

Relevant requirement(s)

1.3.1 Info and Relationships

High-level approach and rule scope

  • Every <table> element that does not also have a role="presentation" or role="none" attribute should have a <caption> element nested as its first child element OR an aria-labelledby attribute with a valid ID. aria-label alone without an on-screen caption is insufficient to meet WCAG 1.3.1.
  • Every element with the role="table" or role="treegrid" attribute should have either an aria-label attribute with text or an aria-labelledby attribute with a valid id (see MDN's ARIA: table role and MDN's ARIA: treegrid role.

Ruleset and failure level

WCAG 2.1

Failure level

Violation Recommendation

Different failure level

No response

Failure cases

Table Elements

  1. Does the <table> element also have the role="presentation" or role="none" attribute? Yes: break... not relevant. No: proceed.
  2. Does the <table> element have a child <caption> element positioned properly as its first child? Yes: pass. No: proceed.
  3. Does the <table> element have an aria-labelledby attribute with a valid id? Yes: pass. No: fail.

Elements with Table Roles

  1. Does an element have a role="table" or role="treegrid" attribute? No: break... not relevant. Yes: proceed.
  2. Does this element have an aria-label attribute with a non-empty value OR an aria-labelledby attribute with a valid id? Yes: pass. No: fail.

Metadata

Metadata

Assignees

No one assigned

    Labels

    engineIssues in the accessibility-checker-engine componentenhancementNew feature or requestuser-reportedIssues identified outside of the core team

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions