r/HTML • u/50_and_stuck • Oct 20 '26
Accessible hyperlinks?
Hey folks!
I am hand coding a series of webpages for my employer (don't ask). I just got dinged because the accessibility checker says my hyperlinks are not accessible.
I scratched my head a little bit, did some research and have since added aria-label attributes to the source code.
Still get dinged.
Anyone know how to handle this?
Thanks!
Edit: Here is more or less an example of the code that includes the link.
2
Upvotes
11
u/TurboHenk Oct 20 '26
So, what did the a11y checker actually give as feedback? Adding aria-label probably does more harm then good, and really shouldn't be necessary on a hyperlink.
Some generic advise:
4
u/chmod777 Oct 20 '26
Without seeing the code, no one can help you. You need to post a clean example with anonymized properties to something like codepen or jsfiddle before anyone can comment.
2
u/armahillo Expert Oct 20 '26
Can you put your code into a codepen or jsfiddle and share it here so we can look?
Theres not enough information here to know for certain. Also what a11y checker are you using?
4
u/pfdemp Oct 20 '26
Don't use the URL for the linked text. The text in your aria-label would be better as the linked text. This improves usability as well as accessibility.
4
u/SamIAre Oct 20 '26
Is it giving a specific issue? There are a couple common problems people run into. One is having multiple links on the same page with identical text: Like a series of cards and each says "Read More", so that there's no way for a user to differentiate them.
Another would be adding an
aria-labelthat doesn't begin with the visible text. For example, you keep your multiple generic links but you give each a unique label to differentiate them. That label must start with the visible text (see Using aria-label for link purpose).3
u/csswizardry Oct 20 '26
Move the value of your ARIA attribute into the content of the element itself. Delete the ARIA attribute. Shorten or improve the text to suit.
3
u/AmanBabuHemant Oct 20 '26
Would be much better if you can share source code also, maybe the are expecting _title_ attribute or something idk.
2
u/lyszcz013 Oct 20 '26
What specific error are you getting? It's difficult to know if this is a false positive or what the issue is without seeing an example or what specific violation your checker is finding.
That being said, while aria-label does have its uses, that should be the last resort for hyperlink accessibility.
Off the top of my head, here are a few things to consider:
1
u/Jasedesu Oct 20 '26
My guess: What you put between the opening
<a>and the closing</a>should be readable by a human, not a naked URL intended for a machine. Usingaria-labelshould be unnecessary.1
u/tjameswhite Oct 21 '26
Just link the url. This is a works cited. The exposed url is fine just make it the link not the other text. No need for aria
0
u/Yasiii92 Oct 23 '26
Link text that makes sense out of context is the big one, since screen reader users often pull up a list of links on their own.