question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

anchor-is-valid should allow named anchors

See original GitHub issue

Shouldn’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:closed
  • Created 5 years ago
  • Comments:6 (3 by maintainers)

github_iconTop GitHub Comments

3reactions
trevorrcommented, Oct 17, 2018

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!

1reaction
trevorrcommented, Oct 17, 2018

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.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found