Use `tabindex="0"` instead of `href="#"` for controls?
See original GitHub issueIdeally <button>
should be used for controls (https://github.com/Leaflet/Leaflet/issues/7821), however migrating from <a>
to <button>
is likely to break a lot of selectors in the wild. Instead, it may be better to use tabindex="0"
for now (same as for markers), as it behaves more similarly to <button>
:
tabindex="0"
does not prompt a URL to be displayed when hovered/focused (more aesthetically pleasing, but also removes a potential source of confusion for some users):tabindex="0"
does not cause a “touch callout” on taphold:
Issue Analytics
- State:
- Created 3 years ago
- Comments:11 (6 by maintainers)
Top Results From Across the Web
Is tabIndex: 0 in links considered a good practice in order to ...
Tabindex=0 will make your links focusable but not clickable. Instead of just using # , use the id attribute of the item which...
Read more >Control focus with tabindex - web.dev
Insert an element into the tab order #. Insert an element into the natural tab order using tabindex="0" . For example:.
Read more >tabindex - HTML: HyperText Markup Language | MDN
The tabindex global attribute indicates that its element can be focused, and where it participates in sequential keyboard navigation ...
Read more >How and when to use the tabindex attribute - bitsofcode
tabindex is a global attribute that can be applied to most HTML elements with content. It controls two things: If an element is...
Read more >How-to: Use the tabindex attribute - The A11Y Project
tabindex is a global attribute that allows an HTML element to receive focus ... Instead, use appropriate interactive elements ( a for links, ......
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
Perfect, we can see if we can land that in another PR. I personally have no objections for adding a
tabindex="0"
here.@jonkoops note that most controls use the correct semantics due to
role="button"
(there are some controls that don’t, I’ve opened issues for those). Anyhow, I’ve opened https://github.com/Leaflet/Leaflet/issues/7821 for moving from<a>
to<button>
.