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

Investigate allowing headings within table captions #3881

Open
3 tasks
36degrees opened this issue Jun 30, 2023 · 1 comment
Open
3 tasks

Investigate allowing headings within table captions #3881

36degrees opened this issue Jun 30, 2023 · 1 comment

Comments

@36degrees
Copy link
Contributor

What

Investigate whether allowing headings within table captions may make it easier for users to understand the hierarchy of information on a page or to navigate the page.

Why

Captions are styled similarly to headings, but are not headings so do not show up in headings lists and are not included when navigating using headings in screen readers.

The content model for the caption element allows for any flow content, which includes headings, so it's a valid thing to do according to the HTML spec.

Assumptions

Including a heading within the caption does not affect the role of either the caption or the heading, nor how they are communicated to users of assistive technologies.

Timebox

TBC

Who is working on this?

Spike lead: TBC

Spike buddy: TBC

Questions to answer

  • Is there any established best practise around this?
  • Do users expect to see table captions included in the list of headings, or to expect them to act as headings e.g. for navigation?
  • In which scenarios does it make sense to put a heading in a caption, if any?
  • What changes do we need to make to allow headings in captions?

Done when

  • Questions have been answered or we have a clearer idea of how to get to our goal
  • Findings have been reviewed and agreed with at least one other person
  • Findings have been shared, e.g: via a write-up on the ticket, at a show & tell or team meeting
@dav-idc
Copy link

dav-idc commented Sep 20, 2023

Here's a bit of investigation work I did into the theoretical and fundamental question of: can heading elements be used within table caption elements?

there doesn’t appear to be any specification-level issue with having a heading <h*> element inside of a <caption>.
I think we’d want to test it with screen readers though, just to be sure screen readers are interpreting headings within captions as just regular ol’ headings.

It’s probably best to check this stuff before making a decision on allowing headings inside captions:

  • do screen readers list the heading in the list of headings they produce?
  • do screen readers use the caption content as the label for the table in the list of tables they produce?

After that, here's some questions we may want to add to our guidance, for teams whenever using headings inside captions across varying services:

  • does the heading styling conflict with local caption styling?
  • does the heading styling look exactly like all other captions when it’s within a caption?
  • does the heading within the caption’s content-writing style match that of the rest of the headings on the page?

Here's some things it’s probably best to disallow (likely via guidance) if a heading is inside a caption:

  • no custom caption styling (background colours, italics, etc.)
  • no multiple flow content elements within that caption
    • for example, no heading then followed by a paragraph, all wrapped inside a caption. If you need paragraph or any other text between the heading and the start of the table, then make a separate heading and caption.

Places I checked for evidence for or against heading elements inside of caption elements:

colinrotherham added a commit to alphagov/govuk-design-system that referenced this issue Dec 1, 2023
colinrotherham added a commit to alphagov/govuk-design-system that referenced this issue Dec 4, 2023
colinrotherham added a commit to alphagov/govuk-design-system that referenced this issue Dec 8, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants