Skip to content

Fix heading hierarchy for accessibility#19824

Open
muratclk wants to merge 1 commit into
pypi:mainfrom
muratclk:fix/heading-structure-accessibility
Open

Fix heading hierarchy for accessibility#19824
muratclk wants to merge 1 commit into
pypi:mainfrom
muratclk:fix/heading-structure-accessibility

Conversation

@muratclk
Copy link
Copy Markdown

@muratclk muratclk commented Apr 9, 2026

Summary

Fixes #18162 — corrects the heading structure on the package detail page to follow proper HTML semantic hierarchy, improving accessibility for screen readers and assistive technologies.

Changes

  • Navigation heading (detail.html): Changed from <h3> to <h2> — as a top-level section under the <h1> project name, it should be <h2>
  • Subsection headings (project-data.html): Changed all <h6> to <h4> — these headings (Project links, Owner, GitHub/GitLab Statistics, Maintainers, Meta, Classifiers) sit under <h3> (Verified/Unverified details) and were incorrectly skipping heading levels 4 and 5
  • Stylesheet (_verified.scss): Updated the selector from h6 to h4 and explicitly set font-size: 1rem to preserve the existing visual appearance

Before

h1: Project Name
  h3: Navigation          ← skips h2
    h3: Verified details
      h6: Project links   ← skips h4, h5
      h6: Meta
    h3: Unverified details
      h6: Project links
      h6: Meta

After

h1: Project Name
  h2: Navigation          ← correct level
    h3: Verified details
      h4: Project links   ← correct level
      h4: Meta
    h3: Unverified details
      h4: Project links
      h4: Meta

Visual Impact

The .sidebar-section__title class already controls the Navigation heading's font size (1.1rem), so the h3→h2 change has no visual effect. For the h6→h4 change, font-size: 1rem is explicitly set in the updated CSS rule to match the previous h6 base style, preventing any visual regression.

Testing

  • Verified heading hierarchy follows semantic HTML structure (h1 → h2 → h3 → h4)
  • Confirmed CSS preserves existing visual appearance through explicit font-size override

Fix heading structure to follow proper HTML semantic hierarchy:
- Change Navigation from h3 to h2 as a main section heading
- Change h6 subsection headings to h4 under h3 parent headings
- Update CSS to preserve existing visual appearance

Co-Authored-By: Paperclip <noreply@paperclip.ing>
@muratclk muratclk requested a review from a team as a code owner April 9, 2026 00:49
@miketheman miketheman added accessibility Issues with accessibility or to improve accessibility HTML requires change to HTML files labels Apr 17, 2026
@miketheman
Copy link
Copy Markdown
Member

Thanks - this looks generally okay, but can you please provide a few before/after screenshots as well?
It would be helpful to understand the implications of these changes to have a direct comparison.

@miketheman miketheman added the awaiting-response PRs and issues that are awaiting author response label Apr 21, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

accessibility Issues with accessibility or to improve accessibility awaiting-response PRs and issues that are awaiting author response HTML requires change to HTML files

Projects

None yet

Development

Successfully merging this pull request may close these issues.

The structure of the different headings is incorrect

2 participants