Make Icon Only Share Links Accessible
Currently, if a site owner uses the "Icon Only" sharing links, they are not accessible to screen readers.
Current markup:
<div class="sd-content">
<ul>
<li class="share-twitter">
<a rel="nofollow" class="share-twitter sd-button share-icon no-text" href="http://mysite.com/2014/01/01/hello-world/?share=twitter&nb=1" title="Click to share on Twitter" id="sharing-twitter-1"><span></span>
</a></li>
<li class="share-end"></li></ul></div>
Why?
- These links use only icon fonts inside the
<a>, but icon fonts are not announced by screen readers. - The
titleattribute may be intended for screen readers, but it's not announced by default by screen readers either, and it's really only useful for users with a mouse. See this post for more info on thetitleattribute. - When a screen reader announces these links, it says: "Link", which isn't descriptive and doesn't tell the user what the link does or where it goes.
Suggestions
Possible markup:
<div class="sd-content">
<ul>
<li class="share-twitter">
<a rel="nofollow" class="share-twitter sd-button share-icon no-text" href="http://mysite.com/2014/01/01/hello-world/?share=twitter&nb=1" title="Click to share on Twitter" id="sharing-twitter-1"><span class="screen-reader-text">Share on Twitter</span>
</a></li>
<li class="share-end"></li></ul></div>
- Links should always have link text.
- The
screen-reader-textwould be hidden off-screen, maintaining the design of these. - Also ideally, if the links open in a new window, it would warn them of that. Like: "Share on Twitter (opens in new window)"
Let me know if there are any questions. Also, happy to test a solution. :smile: Thanks!
This may be a naive question, but if i may ask is there a strong reason for favouring screen reader text over putting an ARIA label on the link? I assume with the former we would have to style .screen-reader-text in sharing.css as it won't necessarily be in every theme.
@chrisdc No, that's a great question. And you have a good point, it's a bit more work. The reason I usually prefer screen-reader-text is that it how better support in all assistive technology devices. ARIA support still varies here and there. It's kind of like browser support for new CSS stuff: good here, not so good there.
This post has a good comparison of text links, ARIA label and title attribute.
Hi @davidakennedy Thank you for bringing this issue up. I have merged the pull request submitted by @chrisdc. The changes should be part of Jetpack 3.2 when it is released.
@enejb and @chrisdc Thanks! This looks good!