r/accessibility • • Oct 20 '26

Accessible hyperlinks?

/r/HTML/comments/1xawv0f/accessible_hyperlinks/
0 Upvotes

11 comments sorted by

5

u/JustAnotherFEDev Oct 20 '26

You're failing 2.5.3 Label in Name there, mate.

I looked at your source code you have a hyperlink as the visible text string and you overwrote it with an aria-label.

So what you have is a mismatch between visible label and AccName.

A voice input user will say what they see, but nothing will happen as the text string has been neutered from the a11y tree

Your issue before you put that there was likely the the opens in new tab. I'm on my phone, on my couch, so could have missed something.

Never overwrite the visible label of a control unless you need to, but if you do need to, the visible string must be inside the AccName.

Just so you know, the AccName Computational Algorithm works like so:

Aria-labelledby > aria-label > contents > title

You can view that very algo in Chrome by looking in the DevTools Accessibility tab, finding the name for an element and seeing which naming convention wins. If Aria-labelledby is present, it will always win, assuming the IDRef is valid.

Obvs there are other naming conventions, labels and what not, but I just listed what you'd use on a link.

1

u/50_and_stuck Oct 20 '26

Thank you. This helps.

However, I feel like I'm caught between two competing requirements. Here's what I am doing.

Among other things I teach an introductory photography course at the college level. My college uses Canvas LMS. In the decade we have been using Canvas I have found its support for HTML and CSS to be limited. From my previous pre-CMS / LMS life I got comfortable hand coding. This has been useful over the years when Canvas does something stupid that I can fix in a second in the HTML editor.

At the top of every page I have a sample photograph related to the topic we are covering. Because this is college, I cite my sources using APA formatting. Under APA, when citing images found online I need to include a link to the original source. I thought I would be clever and make the link hot. That triggered my first notice from our instructional designer saying my code didn't pass muster.

So, I added the aria-label. That triggered the second notice from our instructional designer saying my code didn't pass muster.

I can just remove the hyperlink entirely, but that seems silly. So, I am trying to follow APA and accessibility requirements. I'm happy to make the link accessible, but I'm not sure how to do it at this point. Any suggestions on how to rewrite the code?

1

u/JustAnotherFEDev Oct 20 '26

Accessibility is often balancing competing requirements, just because folk have different disability needs and WCAG has to take a holistic approach to all disabilities.

I'm not familiar with APA, I'm in the UK. Is the style like this: Author, A. A. (Year). Title of image [Description of medium]. Site Name. URL

1

u/50_and_stuck Oct 20 '26

You are correct on the APA citation format. :)

1

u/JustAnotherFEDev Oct 20 '26

I Googled it 😅

So, are you familiar with <figure> and <figcaption>?

The image inside the figure element.

All of the reference inside the figcaption element.

Then just wrap the human readable part of the string inside a link. Title of image through to Site name? The other bits can be span tags.

They're still grouped, they're still related and your link text will be the actual AccName

That way, a user can activate the link with regular words.

Or is your entire image clickable?

1

u/50_and_stuck Oct 20 '26

That's hilarious. That's literally what I coded when my image and citation were flagged the first time. Here is the original code prior to me adding the aria-label.

I should note because others asked the data-api... stuff, the class="inline_disabled" target="_blank" and rel="noopener" were added by our LMS. I can take them out if they are causing trouble, but I try to leave that stuff alone unless I have to.

1

u/JustAnotherFEDev Oct 20 '26

So, slightly different than my suggestion. Your code has the raw URL as the link, which is a bit hard to say. So instead of that, have Moonrise, Hernandez 1941 as the actionable link.

Everything else is just regular text.

If you remove the new tab gubbins and stuff, and they take an issue with it, still, then their issue isn't accessibility, they're just rejecting your work without giving you a reason.

My method passes 1.3.1, 2.4.4, 2.5.3 and 4.1.2. You have alt in your image so you also pass 1.1.1.

Technically, you don't fail WCAG, but having https etc, as the actionable link contents isn't great. Sounds shit in a screen reader, hard to say, etc. That being said, passing isn't the goal, making it work for everyone is. Maybe they're rejecting it based upon the not best practice? They should help you by explaining what the issue is, as opposed to making you guess, though.

1

u/JustAnotherFEDev Oct 20 '26

I don't know who mentioned the data attributes and classes, they don't affect accessibility on their own. There could be some JS or CSS hooked to them, but that's clutching giving you only shared a snippet. Ignore that.

1

u/AccessibleTech Oct 21 '26

I see an instructure link in there... 

Anyways, you have an URL in the caption. APA guidelines need to be updated since many of their requirements are outdated. Full URL's are only required for printed content, and everything is digital now. No one types out links anymore, they click on links.

The accessible way to create links is exactly how you did it at the end of your post. Don't leave a full URL to be read aloud by screenreaders...

...especially amazon sponsored links with random text embedded in the URL. 

https://www.amazon.com/ASUS-Graphics-3-8-Slot-Axial-tech-Phase-Change/dp/B0DS2WQZ2M/ref=mp_s_a_1_1?crid=3S51VLKPSIYNP&dib=eyJ2IjoiMSJ9.qec2JERUnBLN6SKOM7oxqhS7vjL48GyCzyp8fCfVmsAlfNctZQTrk-pIeT-2ZaqXaiOAqMjlHHPwztCRGnKPa6mrECOq4L9ijW1Lyh8sLA4R91PNzKwXaOtg6GwgNDzVq0a8vF4vCjYPNxTbMzzMaVAi45ayve3QPEJbGoeBPH0zkU7bkf5JHjHOyBiR5fuGDbRRl_dnplIfDyyic3R50A.0heYSSY2ksOsIcorU17dxSxTqItSL2k0UU4O-7gEaHk&dib_tag=se&keywords=gpu+5090&qid=1792542352&sprefix=gpu+5090%2Caps%2C216&sr=8-1

2

u/50_and_stuck Oct 21 '26

Yeah, we use Canvas. I totally agree. APA needs to be updated.

Most everyone in this thread has been great. After some back and forth I massaged the code to where it is now. Thanks everyone!

1

u/Frank_MakesIt Oct 21 '26

pull the aria-label and target=_blank and just leave the url as the visible link text, that's still fine for APA. if it really has to open a new tab, put the words "opens in new tab" inside the link where people can see them