Proposal for new a11y check to disallow empty anchor elements
See original GitHub issueCurrently, ember-template-lint disallows unhelpful link text such as “click here” via the no-invalid-link-text rule. However, there is nothing in place to prevent empty link text, which is even more harmful. When a link contains no content, the link’s href
ends up as the accessible name. This results in a poor experience and requires the user to resort to trial and error to determine the purpose of the link.
This proposes the authoring of a new rule that disallows empty anchor elements and LinkTo
helpers. Hidden links should be ignored, while alternatively labeled links (using aria-label
or aria-labelledby
) should pass. This is essentially a port of JSXs A11y anchor-has-content rule.
Issue Analytics
- State:
- Created 2 years ago
- Reactions:1
- Comments:6 (3 by maintainers)
Top Results From Across the Web
Quick tip: Creating valid and accessible links - The A11Y Project
Start with valid HTML To be a valid link it must have: A href attribute: The location of the anchor, page or resource....
Read more >eslint-plugin-jsx-a11y/anchor-is-valid.md at main - GitHub
Static AST checker for a11y rules on JSX elements. ... JavaScript strings, empty values or using only # are not considered valid href...
Read more >A11y for empty anchor tag - Stack Overflow
The problem I have is that we need to add the equivalent of an alt-text to this link. Since anchor tags do not...
Read more >Links with identical accessible names have equivalent ... - W3C
Description. This rule checks that links with identical accessible names resolve to the same resource or equivalent resources.
Read more >Empty Link - Equalize Digital
How does Accessibility Checker test for empty links? ... If there is no anchor text and no aria-label or screen reader text, an...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Those aren’t really the same thing though. This disallows links with no text content
<a href="https://foo"></a>
, whilelink-href-attributes
disallows links without anhref
attribute.Seems like the existing rule
no-invalid-link-text
could be updated to enforce this additional check?