-
Notifications
You must be signed in to change notification settings - Fork 73
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
Add tabindex
Closes #85
#86
Conversation
`tabindex="-1"` is to make the user agent focus on the anchor (the targets of anchor links can then be styled using `:focus`).
I'm confused as on MDN I can read
And I can confirm that doing |
My PR is about adding this to headings (anchor destination), not links (anchor source). Did I assume wrongly that the slug can only be added to headings? :-( I created this page to show the "native" behavior (no CSS added) of target elements being focusable or not. Markdown for these would resemble to this:
Clicking on https://thierryk.github.io/anchors/#a and then on https://thierryk.github.io/anchors/#b shows the benefit of making the target focusable. Even more when that element is a heading, a The advantage of As a side note, using |
Ohh sorry I got confused and thought this was putting the attribute on the link, it makes much more sense now! So if my understanding is correct, setting |
Correct! (for when it comes to sequential navigation)
Correct! Voice Over will announce the heading and link after clicking on the "Section B" link, but will remain silent after clicking on the "Section A" link. Note that we can (visually) experience a similar feedback by following these 2 links: without tabindex vs. with tabindex. With the first link, the UA (browser) does not provide a visual cue about what the target is while with the second link, it applies a focus ring on that element. I wonder why there is no default styling for |
As a side note, if I recall correctly, OldIE would scroll to the anchor but would not start tabbing navigation from that point unless that anchor had received focus. I recall having to add |
Awesome, that looks good to me, thank you! I'll publish it later next week as part of a new version I'm working on :) |
tabindex="-1"
is to make the user agent focus on the anchor and more...