Accessibility

Simplified WCAG guidelines

WCAG 2.2 – Levels A and AA only, with dev notes.

How to disable a link in an accessible manner

This method keeps the link visible, and its current state reported, to assitive tech whilst preventing activation.

Examples

Styling is beyond scope, and up to the designer, so lets just consider the basic link:

Working "scroll to bottom" link
Disabled link (removed from keychain)
Disabled link (remains in keychain)
Example HTML
<a role="link" aria-disabled="true">Disabled link (removed from keychain)</a>
<a role="link" aria-disabled="true" tabindex="0">Disabled link (remains in keychain)</a>
<a role="link" href="#h1" tabindex="0">"Back to top" - An example of a reactivated disabled link</a>

How to achieve

And to re-enable:

Please also consider:

In-page anchor targets

If the anchor target is not natively focusable, then it requires both a valid id and a tabindex="-1", otherwise keyboard focus remains on the activating link.

Also, consider adding :target {scroll-padding-block-start: 2rem;} to the targets CSS to keep it away from the viewport top.

What about disabling buttons?

The TLDR is just don't. It's bad for accessibility. See the references in the footer.

What to do instead

  1. Write clear label and hint text so users understand the question
  2. Start with one thing per page to reduce cognitive load
  3. Enable the button so users always get feedback
  4. Forgive trivial mistakes to avoid unnecessary errors
  5. Give clear error messages to help users fix the issue

Adam Silver: The problem with disabled buttons and what to do instead