-
Notifications
You must be signed in to change notification settings - Fork 62
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
Card links do not have a discernible name (accessibility issue) #78
Comments
Thanks for opening your first issue here! Engagement like this is essential for open source projects! 🤗 |
Hey @bertiewooster, I'm afraid I don't know exactly what this means. It would perhaps be really helpful, if you could post what the current generated HTML is, for a minimal card example, and what the desired HTML would be? |
Hi @chrisjsewell, thanks for your response. Current generated HTMLHopefully this pre-existing example will clarify the accessibility issue. With a cardThe first card link (anchor) is
There is no name for the link (link text) indicating the topic of the link: If you were to put this HTML in a web page absent its context, nothing would be presented to the user because there is no text (or image) within the anchor element. Therefore, a screen reader will not be able to speak a useful name to a visitor, so they will now know if they want to follow this link. Without a cardContrast this with the same link without using cards
where the link text is Installation, which a screen reader will speak to the visitor, who can then decide if they want to follow this link. Desired HTMLNaive, sub-optimal approachIf the link text Installation were simply added inside the card anchor, it would
Approach which should work for both visual display and screen readersI found the recommendation to include
I checked that making such a modification does not cause Installation to appear twice on a screen. It would be best to verify that a screenreader speaks Installation (as the An expert in accessibility and HTML might have a better solution. |
Thanks for the explanation @bertiewooster 😄 I'll see what I can do about achieving this |
See #89, for what I felt was the simplest solution. Thoughts welcome? |
This PR adds the `link-alt` option to `card` (and `grid-item-card`) directives, in order to assign a discernable name to the link (for screen readers). As noted in #78, it may be ideal to add `aria-label/`aria-hidden` to the actual link `<a>` HTML element. However, this would entail having to override aspects of the sphinx HTML builder. Instead, we include the link alt text, but add a `sd-hide-link-text` CSS class, to set `font-size: 0`, to hide the text. This solution was taken from https://stackoverflow.com/questions/471510/hide-text-using-css, and seemed to be the simplest solution. fixes #78
Describe the bug
context
When I use cards on a Sphinx site, with Furo theme
expectation
I expected the card link to have a discernible name so people using screen readers can tell what the link leads to
bug
But instead the link has no discernible name
Here's the warning from Lighthouse's accessibility checker:
problem
This is a problem for people using screen readers because they will not be read a name for the link that will help them decide if they should follow the link.
Reproduce the bug
Here is a page built using cards. Here is the corresponding accessibility report from Lighthouse.
List your environment
The text was updated successfully, but these errors were encountered: