Skip to main content
WCAGrules
Quick navigation

Do not emulate links with scripted spans

A span with a click handler that navigates is broken in three separate ways at once. F42 is the documented failure that names all three, filed under info and relationships, keyboard, and name, role and value. One repair mends every one of them. There is a middle state worth knowing about, because it is what a partial fix produces. Add a tabindex and a button role and the element becomes reachable and gets announced as a control, and it is still not announced as a link, so it stays out of the links list a screen reader user navigates by. The ARIA link role can technically supply that, and the published advice is against reaching for it, because the anchor element already exists and already does all of this. The answer is an anchor with an href.

How we find it in an audit

Two checks settle it and they are the two the published procedure names. Is the element's programmatically determined role link, and can it be activated from the keyboard. We run both, plus a third of our own, which is whether it appears in the links list, because that is the route most users would actually take to it. Automated tools find click handlers on non-interactive elements reliably, so the shortlist is cheap and the verification is quick.

How affected users experience it

Screen reader users navigate by links, constantly, pulling up every link on a page and reading down the list to decide where to go. A fake link is not in that list, so as far as the fastest route through your site is concerned it does not exist. It is also not reachable by Tab, not addressable by voice, and not marked in braille as anything you can follow. The page looks like it has twelve links and behaves like it has eleven.

Passes vs. fails

Passes: name, role, and state exposed. Fails: a control with no identity.

Passes

<a href="/pricing">Pricing</a>

Fails

<span class="link" onclick="location.href='/pricing'">Pricing</span>

How this gets tested

The W3C publishes test rules that define what a checker looks for here.

The other techniques filed under this rule

52 guides on this site are filed under 1.3.1 Info and Relationships. W3C documents this one as a failure of that rule, so it describes a way the rule gets broken rather than a way to pass it.

This guide is our interpretation of W3C technique F42: Failure of Success Criteria 1.3.1, 2.1.1, 2.1.3, or 4.1.2 when emulating links. W3C publishes its techniques as guidance rather than as the standard, and says so on every one of them. The success criterion is what conformance is measured against, and a technique is one documented way to meet it.

Go somewhere useful

Find tools, resources and your workspace.

29 destinations