anchor-is-valid should allow named anchors
See original GitHub issueShouldn’t the following be considered valid?
<a name="my-anchor">...</a>
It currently generates warnings:
The href attribute is required for an anchor to be keyboard accessible. Provide a valid, navigable address as the href value. If you cannot provide an href, but still need the element to resemble a link, use a button and change it with appropriate styles. Learn more: https://github.com/evcohen/eslint-plugin-jsx-a11y/blob/master/docs/rules/anchor-is-valid.md jsx-a11y/anchor-is-valid
Issue Analytics
- State:
- Created 5 years ago
- Comments:6 (3 by maintainers)
Top Results From Across the Web
anchor-is-valid should allow named anchors #492 - GitHub
The href attribute is required for an anchor to be keyboard accessible. Provide a valid, navigable address as the href value.
Read more >Valid to use <a> (anchor tag) without href attribute? [duplicate]
The <a> nchor element is simply an anchor to or from some content. Originally the HTML specification allowed for named anchors ( <a ......
Read more >Links in HTML documents - W3C
An anchor name is the value of either the name or id attribute when used in the context of anchors. Anchor names must...
Read more >CMS Basics: Using Link Anchors - University of Houston
Anchor IDs allow you to create a modified link which can direct a site visitor to ... Anchor Names (Named Anchors) were widely...
Read more >eslint-plugin-jsx-a11y - npm
You can also enable all the recommended or strict rules at once. ... anchor-is-valid: Enforce all anchors are valid, navigable elements.
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 Free
Top 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
I did some more research, and the HTML5 spec calls it “obsolete but conforming”. That’s not as strong as deprecated, but I suppose it’s official enough that there’s no point in changing the rule. Thanks for the quick response, @ljharb!
I just meant by styling. I’ve seen pages that use a faint dotted underline on anchors that are intended for external linking.
Anyway, you’re probably right that I could just use
id
instead. Still, it doesn’t seem like this rule should flag<a name>
as invalid just because there are other ways to accomplish an anchor.