research/new-tab-links-for-screen-readers
Telling Screen-Reader Users a Link Opens a New Tab: Hidden Text or aria-label?
Engineering Note · November 10, 2026 · 6 minute read · Accessibility · HTML · Playwright
Use visually hidden text inside the link. It adds “(opens in a new tab)” to the link’s accessible name and leaves the visible words in place. An aria-label can also work, but it replaces what is inside the link, so the label has to repeat the visible words exactly or the two drift apart.
The accessible name is the text a browser hands to assistive technology as the link’s name. We read it directly instead of guessing.
Everything below was run with Node.js 22.23.4, Playwright 1.63.0 and Chromium 153.0.8010.12 on Linux. The outputs are the real ones from this run.
What did we test?
Seven links, all with target="_blank" and rel="noopener", on one small page:
| Link | What is in the markup |
|---|---|
| a | Visible text only: Read the docs |
| b | Same visible text, plus aria-label="Read the docs (opens in a new tab)" |
| c | Same visible text, plus a visually hidden <span> with (opens in a new tab) |
| d | Visible text Read the docs, but aria-label="Documentation (opens in a new tab)" |
| e | An image with empty alt and nothing else |
| f | The same image, plus a hidden span reading Our GitHub page (opens in a new tab) |
| g | Read the docs plus an arrow in a span marked aria-hidden="true" |
The hidden span uses the common visually-hidden pattern. It stays in the page for assistive technology and takes up no visible space:
.sr-only {
position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0;
overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0;
}
How do you read a link’s accessible name in a test?
Playwright can ask Chromium for the whole accessibility tree through the DevTools Protocol, then we filter for links:
const cdp = await page.context().newCDPSession(page);
await cdp.send('Accessibility.enable');
const { nodes } = await cdp.send('Accessibility.getFullAXTree');
const links = nodes.filter(n => n.role?.value === 'link');
links.forEach((n, i) => console.log(ids[i], JSON.stringify(n.name?.value),
'| source:', n.name?.sources?.find(s => s.value)?.type));
Output:
a "Read the docs" | source: contents
b "Read the docs (opens in a new tab)" | source: attribute
c "Read the docs (opens in a new tab)" | source: contents
d "Documentation (opens in a new tab)" | source: attribute
e "" | source: undefined
f "Our GitHub page (opens in a new tab)" | source: contents
g "Read the docs " | source: contents
The source column tells you where the name came from. contents means the browser built it from the text inside the link. attribute means it came from aria-label.
What do the results show?
Link a has no warning. Nothing tells a screen-reader user that activating it opens a new tab.
Links b and c produce the same name. The difference is how they get there. In c the warning is content, so the visible “Read the docs” and the warning travel together. In b the label is a separate string that someone has to keep in sync.
Link d shows the risk. Sighted visitors see “Read the docs”. The accessible name is “Documentation (opens in a new tab)”. Anyone who uses speech control and says the visible words may find the link does not answer to them, because the name no longer contains them. We did not test speech-control software here, only the name Chromium computed.
Link e has an empty name. A link around an image with empty alt has nothing to announce. This is a general accessibility bug, and the new-tab warning cannot fix it on its own.
Link f fixes e with hidden text. The span supplies the whole name.
Link g shows that an aria-hidden arrow contributes nothing. The name is “Read the docs ” with a trailing space and no mention of a new tab. A decorative arrow is fine, but it cannot be the only signal.
ariaSnapshot() gives a shorter view of the same thing and is easier to assert on in a test:
console.log(await page.locator('body').ariaSnapshot());
- link "Read the docs":
- /url: https://example.com
- link "Read the docs (opens in a new tab)":
- /url: https://example.com
- text: Read the docs
- link "Read the docs (opens in a new tab)":
- /url: https://example.com
(output shortened)
The second entry is link b. The snapshot lists the visible text as a separate child, which makes the aria-label override easy to spot: the name and the text differ.
Does the hidden text show up anywhere else?
One side effect surprised us. We read link c’s text two ways:
innerText: "Read the docs\n(opens in a new tab)"
textContent: "Read the docs (opens in a new tab)"
textContent keeps the phrase on the same line. innerText put it on a new line, because the absolutely positioned span becomes its own block. Code that copies a link’s innerText, for example to build a title or a log line, will pick up the phrase with a line break. If your tests assert on innerText, account for it.
What should we do on our own sites?
We would use this checklist:
- Put the warning inside the link, in a visually hidden span, with a leading space.
- Leave
aria-labeloff links that already have visible text, unless the label begins with the visible words. - Give image-only links a text alternative, either
alton the image or hidden text. - Add a test that reads the accessibility tree and fails when a
target="_blank"link has a name without “new tab”. - Do one pass with a real screen reader. This test covers the name, and the reading experience is a separate question.
The test in step 4 is short:
const bad = [];
for (const a of await page.locator('a[target="_blank"]').all()) {
const snap = await a.ariaSnapshot();
if (!/new tab/i.test(snap.split('\n')[0])) bad.push(await a.getAttribute('id'));
}
if (bad.length) throw new Error('No new-tab warning: ' + bad.join(', '));
We ran this against the page above, and it printed FLAGGED a,e,g. We did not run it against a production site for this note.
Limitations
- We read Chromium’s accessibility tree. We did not run NVDA, JAWS, VoiceOver or TalkBack, and each one may speak the name differently.
- We tested one browser engine. Firefox and Safari compute names by the same published rules, but we did not run them here.
- We did not test speech-control software, so the point about link d is a reading of the computed name, not an observed failure.
- Opening links in a new tab is a design choice with its own trade-offs for all users. This note only covers how to announce it when you do.
Related reading
- An internal link checker for a static build in 34 lines of Node.js
- The WCAG contrast ratio in 20 lines
- Autoplaying a background video only while it is on screen
Frequently asked questions
How do I tell screen-reader users that a link opens in a new tab?
Add a short phrase such as "(opens in a new tab)" inside the link, in an element hidden with the visually-hidden CSS pattern. The phrase becomes part of the link's accessible name, so it is announced with the link. In our test the name came out as "Read the docs (opens in a new tab)".
Should I use aria-label or visually hidden text for a new-tab warning?
We prefer visually hidden text. An aria-label replaces everything inside the link, so the visible words and the label can drift apart when someone edits one. In our test, a link showing "Read the docs" with an aria-label of "Documentation (opens in a new tab)" was named "Documentation (opens in a new tab)", and the visible words were gone from its name.
Does an icon next to the link count as a warning?
Only if it has a text alternative. An arrow marked aria-hidden is skipped, which is right for decoration, but then it warns nobody who cannot see it. Our test link with a hidden arrow was named "Read the docs", with nothing about a new tab.
How do I check what a link's accessible name is?
Ask the browser. With Playwright you can print a page's accessibility tree through the Chrome DevTools Protocol, or call ariaSnapshot() on a locator. Both show the name the browser computed for each link, which is the text assistive technology starts from.
Does this replace testing with a real screen reader?
No. The accessibility tree shows the name a browser exposes. It does not show how a particular screen reader reads it aloud, so a manual pass with one is still worth doing.