accessible-html-links
Use when writing or reviewing HTML navigation, vague link text, external links, role=link, onclick navigation, or elements that imitate links. Enforce native anchors, descriptive purpose, valid interactive nesting, and safe external navigation.
- License 许可
- MIT
- 所属仓库
- jeswr/solid-sdk
- 最近更新
- 2026-11-15
- Stars
- ★ 2
- Forks
- 0
01 前言 Front Matter
- name
- accessible-html-links
- metadata
- { "author": "derived from csarven's review feedback on solid/solidproject.org#956", "version": "1.0.0" }
- description
- Use when writing or reviewing HTML navigation, vague link text, external links, role=link, onclick navigation, or elements that imitate links. Enforce native anchors, descriptive purpose, valid interactive nesting, and safe external navigation.
03 SKILL.md 正文
Quick reference
<!-- AUTHORED-BY Codex GPT-5 -->
Write accessible links
If an element navigates, use <a href>. Use <button> for an action. Do not emulate either with a div or span.
Review checklist
- Replace
role="link",tabindex="0", andonclicknavigation with a real anchor. - Give visible link text a purpose that makes sense in context. Replace “click here”, “here”, and ambiguous “read more” text.
- Do not use
aria-labelto conceal vague visible text; improve the visible text. - Reject nested interactive content such as an anchor inside an anchor or button. Restructure the card or expose separate sibling links.
- Preserve browser affordances: address preview, copy link, open in new tab, history, keyboard activation, and crawler discovery.
- Links activate with Enter. Space activation indicates button behavior.
- Use
target="_blank"only when opening a new context is genuinely helpful. For external new-context navigation, includerel="noopener noreferrer". - In React/router code, ensure the rendered result is still a native anchor with a real
href.
<!-- Avoid -->
<span role="link" tabindex="0" onclick="location.assign('/docs')">click here</span>
<!-- Prefer -->
<a href="/docs">Read the API documentation</a>
Search reviews for role="link", window.location, onclick, non-native tabindex, nested anchors, target="_blank", and vague link text. Prefer native HTML before adding ARIA.
Agent persona
When this work is delegated to a sub-agent, spawn the solid-frontend-dev persona from
.claude/agents/solid-frontend-dev.md — it routes through this skill.
Orchestration: .claude/agents/solid-app-orchestration.md.
<!-- AUTHORED-BY Codex GPT-6.1-Sol -->
Accessible HTML Links
Checklist for any anchor-like construct in HTML. Apply when authoring new markup and when reviewing existing markup.
The one rule
If it navigates, it is an <a href>. Not a <span>, not a <div>, not a
<button>. Everything below follows from this.
Markup anti-patterns to reject
<span role="link">/<div role="link">— A non-interactive element given link semantics via ARIA. Partial patch: loseshrefinspection by assistive tech, loses browser history integration, loses right-click / middle-click / prefetch.onclick="window.location.assign(...)"— Imperative navigation in place of a declarativehref. Strips the same browser affordances and makes the link invisible to crawlers and preloaders.tabindex="0"on a faux link — Only needed because the element isn't natively focusable. Redundant once you use<a>.onkeydownthat activates on bothEnterandSpace— That is the button activation pattern, not the link activation pattern. Per WAI-ARIA 1.2, thelinkrole activates onEnteronly. Mixing them creates inconsistent keyboard behaviour for assistive-tech users.return falseinside an inlineonclick— Only suppresses the element's default action. A<span>has none, so the statement is a no-op there. Not equivalent toevent.preventDefault()+event.stopPropagation().- Nested interactive content —
<a>inside<a>(or<a>inside a<button>) is invalid per the HTML spec. If you need two targets inside one visually-grouped card, move the inner link OUTSIDE the outer anchor (e.g., below the tile, or into a separate<p>).
Link text (WCAG 2.4.4 / 2.4.9)
- Never "click here" or "here" — the link text alone must describe its purpose.
- Avoid
aria-labelas a primary fix — it only helps screen-reader users; sighted keyboard users scanning the page still see the vague text. Rewrite visible text instead. - Prefer:
Source code on GitHub (MyApp)over<span aria-label="...">here</span>.
rel and target on external links
- External links:
rel="noopener noreferrer". Include even withouttarget="_blank", as a defence-in-depth againstwindow.openerreference leaks. - Use
target="_blank"only when there is a user-visible reason (e.g., external docs while filling a form). It is not an accessibility improvement by default.
First Rule of ARIA
From the WAI-ARIA spec: if a native HTML element exists that already has
the semantics and behaviour you need, use it rather than re-purposing
another element with an ARIA role. The presence of role="link" on
anything other than an <a> is almost always a mistake.
Canonical corrected pattern
Replace this:
<span class="external-link" role="link" tabindex="0"
aria-label="Open the MyApp source on GitHub"
onclick="event.preventDefault(); event.stopPropagation();
window.location.assign('https://github.com/x/y'); return false;"
onkeydown="if(event.key==='Enter'||event.key===' '){
event.preventDefault(); event.stopPropagation();
window.location.assign('https://github.com/x/y'); }">here</span>
With this:
<a href="https://github.com/x/y" class="external-link" rel="noopener noreferrer">GitHub (MyApp)</a>
How to apply in reviews
When reviewing HTML:
- Grep for
role="link",onclick="window.location,tabindex="0"on non-interactive elements, and literal link text ofhere,click here,read more,link. - For each hit, propose the corrected
<a href>form and a self-describing link text. - If the hit is inside another
<a>(nested interactive content), flag it and suggest restructuring the container — typically by moving the inner link out of the outer anchor, or by demoting the outer anchor to a heading-level link. - Confirm
rel="noopener noreferrer"on external links. - For keyboard behaviour: links activate on
Enteronly. If a handler also responds toSpace, either switch to<button>(if the control is an action, not navigation) or drop theSpacebranch.
Specification references
- First Rule of ARIA — https://www.w3.org/TR/using-aria/#rule1
- WAI-ARIA 1.2,
linkrole — https://www.w3.org/TR/wai-aria-1.2/#link - WAI-ARIA Authoring Practices, Link Pattern — https://www.w3.org/WAI/ARIA/apg/patterns/link/
- WCAG 2.1 SC 2.4.4 Link Purpose (In Context) (AA) — https://www.w3.org/TR/WCAG21/#link-purpose-in-context
- WCAG 2.1 SC 2.4.9 Link Purpose (Link Only) (AAA) — https://www.w3.org/TR/WCAG21/#link-purpose-link-only
- HTML Living Standard,
<a>— https://html.spec.whatwg.org/multipage/text-level-semantics.html#the-a-element - HTML Living Standard,
rel=noopener— https://html.spec.whatwg.org/multipage/links.html#link-type-noopener
04 同仓库更多 Skills
storage-conformance
Work on @jeswr/storage-conformance, the shared storage conformance suite package in the Solid SDK workspace.
fetch-rdf-engine-tests
Maintain fetch-rdf's real Node WASM parser integration tests without introducing a reverse engine dependency in fetch-rdf.
alpha
Use when checking fixtures, including folded YAML descriptions.
widget
Use when testing package skills: YAML quoting works.
web-seo
Use when improving technical and entity SEO for a modern personal, portfolio, documentation, or marketing site, including crawlable HTML, canonical metadata, sitemap and robots, Person/ProfilePage JSON-LD, Core Web Vitals, and honest ranking expectations.
solid-wac
Use when implementing or auditing Solid server WAC authorization, ACL creation and inheritance, auxiliary-resource escalation, method-to-mode mapping, 401 versus 403 challenges, WAC-Allow, or defensive typed ACL parsing with @solid/object and @rdfjs/wrapper.