-
-
Notifications
You must be signed in to change notification settings - Fork 4.5k
A11y: Warning on missing href on anchor tag when role="button" #1719
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
An anchor tag isn't a button. I vote it should warn on missing hrefs. |
Please consider these examples: <a role="button" class="nav-link dropdown-toggle" href="#" id="navbarDropdown" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
Dropdown
</a> <a role="button" class="navbar-burger" aria-label="menu" aria-expanded="false">
<span aria-hidden="true"></span>
<span aria-hidden="true"></span>
<span aria-hidden="true"></span>
</a> |
YES! Svelte should warn in that case. As far as I know you can’t emit the href attribute from an anchor tag. It’s simple: use button element for “actions” and anchor element for navigation. With a valid href of course. Those are bad examples when it comes to accessibility. They should both be a button with type=“button” to prevent it from “submitting”. Try those examples in a screen reader and compare it to using a button element instead. |
Responded over on #1763. My inclination is to close this issue — just use a |
Just noting here that the specs say its valid to have an
I tend to omit the |
I just checked, and neither Chrome nor Firefox let you tab to an |
Is there an option for disabling these warnings? I'm trying to use Bulma, which depends on un-anchored |
If you are using rollup-plugin-svelte, there's an Edit: The |
By the way.. I ran into the same thing.. What I found worked w/ Bulma was the following :
instead of
Using doesn't alter the appearance on the loaded page like using did for me -- it worked but the rendered font label was really small.. Using seems to work just fine -- no warnings, no issues. |
Gotta use that button @ps23Rick 🙂 |
I found this workaround though
|
The null workaround by @igbanam doesnt seem to render the link properly (no anchor like styling on hover). For me this worked fine:
|
At the moment, svelte will warn if an
<a role="button" {...}>{...}</a>
tag is missing anhref
attribute, but, changing these tags tospan
(and thus, getting rid of the warning) is a detriment to accessibility.Should svelte warn if an href attribute is missing on an anchor whose role is button?
The text was updated successfully, but these errors were encountered: