In Page Navigation (USWDS Style)

Version: 1.1

This is an enhanced version of the US Web Design System (USWDS) In-Page navigation (aka Table of Contents) element. Jump to demo. If you are looking for a high-quality TOC that is a little less complex, check out Zach Pyle’s on SnippetNest.

  • Title: The visible heading displayed above the table of contents (for example, “On this page”). This identifies the navigation section for users.
  • Heading Level: Determines the HTML heading tag for the TOC title (e.g., h2 or h3). This should fit properly into the page’s heading hierarchy for accessibility and SEO.
  • Hide TOC Title: Visually hides the TOC title while keeping it available to screen readers. Useful when the layout already includes a visible section heading.
  • Target: The CSS selector of the container where headings will be scanned (e.g., .article, main). Only headings inside this container will be included in the TOC.
  • Heading Level Depth: Controls which heading levels are included in the TOC. Examples:
    • h2 → only H2s
    • h2-h3 → H2 and H3
    • h2-h4 → H2 through H4. This determines how deeply nested the TOC becomes.
  • Aria Label: Sets the accessible label for the <nav> landmark. This helps screen reader users understand the purpose of the navigation region.
  • Show Border: Toggles the vertical border indicator on the left side of the TOC list.
  • Minimum Number Of Headings: The minimum number of detected headings required before the TOC is rendered. If there are fewer headings than this value, the TOC will not display.
  • Collapse Subheadings: When enabled, subheadings (e.g., H3 under H2) are collapsed by default and only expand when their parent section is active. When disabled, all nested headings remain visible.
  • Scroll Offset (px): Adjusts how far down the viewport a section is from the top when clicked. This prevents headings from being hidden under sticky headers.
  • Use Accordion: Enables responsive TOC accordion behavior. When active, the TOC can collapse/expand at smaller screen sizes.
  • Accordion Breakpoint (px): The viewport width at which accordion behavior activates. Below this width, the TOC becomes collapsible.
  • Accordion Expanded By Default: Determines whether the TOC panel starts expanded or collapsed when accordion mode is active.

This guide outlines the federal requirements for digital accessibility under Section 508 of the Rehabilitation Act. All federal agencies must ensure their electronic and information technology is accessible to people with disabilities.

Understanding Section 508

Section 508 requires federal agencies to make their electronic and information technology accessible to people with disabilities. This applies to all technology developed, procured, maintained, or used by the federal government. Compliance ensures that both federal employees and members of the public who have disabilities have equal access to information and services.

The U.S. Access Board publishes the Section 508 Standards, which are the technical requirements that federal agencies must follow. These standards were refreshed in 2017 to incorporate WCAG 2.0 Level AA success criteria, bringing them in line with international accessibility guidelines.

Scope of applicability

Section 508 applies to all information and communication technology that federal agencies develop, procure, maintain, or use. This includes websites, software applications, electronic documents, telecommunications products, video and multimedia products, and self-contained closed products such as kiosks and copiers. Contractors who build ICT on behalf of federal agencies are also required to meet these standards.

Agencies must ensure accessibility is addressed from the very beginning of the development or procurement lifecycle. Incorporating accessibility early in the process is far more cost-effective than retrofitting after deployment. Agencies should include accessibility requirements in all solicitations and contracts for ICT.

Key compliance requirements

Federal agencies must perform regular accessibility testing on their digital products and services. This includes automated scanning, manual keyboard testing, and screen reader verification. Agencies are expected to document their testing processes and maintain records of accessibility conformance for each ICT product.

WCAG 2.1 Guidelines

The Web Content Accessibility Guidelines provide a shared standard for web content accessibility. The guidelines are organized around four principles: Perceivable, Operable, Understandable, and Robust. Each principle has specific guidelines and success criteria, organized into three levels of conformance: A, AA, and AAA.

Level AA conformance is the standard referenced by Section 508 and most international accessibility laws. Achieving this level means your content can be accessed by a broad range of users, including those with visual, auditory, physical, speech, cognitive, language, learning, and neurological disabilities.

Perceivable content

Information and user interface components must be presentable to users in ways they can perceive. This means providing text alternatives for non-text content, providing captions and other alternatives for multimedia, and creating content that can be presented in different ways without losing information or structure.

Operable interfaces

User interface components and navigation must be operable by all users. This requires making all functionality available from a keyboard, giving users enough time to read and use content, and not designing content in a way that is known to cause seizures. Navigation should be clear, predictable, and easy to use.

Understandable information

Information and the operation of the user interface must be understandable. Text content should be readable and understandable, and web pages should appear and operate in predictable ways. Users should be helped to avoid and correct mistakes through clear labeling, instructions, and error messages.

Testing and validation

Effective accessibility testing combines automated tools with manual evaluation. Automated testing tools can catch many issues quickly but typically identify only 30 to 40 percent of accessibility barriers. Manual testing by people who use assistive technologies is essential for identifying the remaining issues and ensuring a truly accessible user experience.

Common testing methodologies include keyboard-only navigation testing, screen reader testing with tools like JAWS, NVDA, and VoiceOver, and color contrast analysis. Regular testing should be integrated into your development workflow rather than treated as a one-time event. Continuous integration pipelines can include automated accessibility checks to catch regressions early.

Automated testing tools

There are several established automated testing tools available, including axe-core, Lighthouse, WAVE, and Pa11y. These tools scan your pages and report violations against WCAG success criteria. While they cannot catch every issue, they provide a valuable first line of defense and help teams quickly identify common problems like missing alt text, insufficient color contrast, and improper heading hierarchy.

Manual evaluation techniques

Manual testing complements automated tools by catching issues that require human judgment. Key techniques include navigating the entire site using only a keyboard, testing with screen readers to verify that all content is announced correctly, and checking that interactive elements have clear focus indicators. Usability testing with people who have disabilities provides the most reliable assessment of real-world accessibility.

Reporting and remediation

When accessibility barriers are identified, agencies should prioritize remediation based on the severity of the issue and its impact on users. Critical issues that prevent access to essential content or functionality should be addressed first. A Voluntary Product Accessibility Template can document the accessibility status of a product and help guide purchasing decisions. Regular reporting to agency leadership helps maintain accountability and ensures that accessibility remains a priority in the development lifecycle.

CSS LogoA purple square with rounded corners and the letters CSS inside in white

AI Statement

AI used to translate USWDS JS.

Changelog

  • 1.0.0Initial release.

  • 1.1New multi-target and exception options added by Tom Homer.

ACSS Usage

Automatic.CSS (ACSS) is used in most components and patterns, but in the event you aren't using it, you should be able to easily update the CSS if you are not using it.

Usage

This work is marked CC0 1.0 Universal