1

In a recent edit I made on UX Stack Exchange, I added some alt text to an image that contained the URL of a page at which the reader could see a textual version of the content in the image.

However, I'm unsure whether including links in alt text like this is actually useful. How will a screen reader handle such a URL? Does software typically used by blind or vision-impaired users provide a means to visit such URLs - for instance, by enabling them to copy the alt text to the clipboard? Or is such a link effectively impossible to follow for the audience at which it is aimed?

1

There is the longdesc attribute that is supposed to be supported by screenreaders and it serves exactly the purpose.

  • Hmm. longdesc is interesting and relevant, but this doesn't directly answer the question (and there seems to be at least one good reason not to use it: namely, that it has incomplete support (according to your source). – Mark Amery Mar 26 '18 at 13:25
  • Well, obviously alt is not the way to go. mdn also describes it as a 'link to description' placeholder. – xpy Mar 26 '18 at 13:28
  • With a bit more research, longdesc is supported by NVDA and JAWS which adds up to almost 80% of the screen reader users – xpy Mar 26 '18 at 13:37
  • "Well, obviously alt is not the way to go" - uh, why? This is entirely non-obvious to me, or else I wouldn't've asked the question. Besides the fact that longdesc isn't supported everywhere, how else do the behaviours of alt and longdesc differ? – Mark Amery Mar 26 '18 at 15:24
  • "longdesc is supported by NVDA and JAWS" - your own linked source paints a somewhat more nuanced picture than that. Yes, NVDA and JAWS support longdesc... when working with IE or Firefox, but not with Chrome. – Mark Amery Mar 26 '18 at 15:29
1

The alt attribute is for plain text. So it can’t contain hyperlinks, but it can contain URLs.

Custom implementations aside, a screen reader wouldn’t offer to visit the URL, but it would read it out. Depending on the screen reader, the user might have to switch to a different mode to also hear the punctuation (the parts "https" and "www" should suffice as indicators for recognizing that it’s a URL).

So at that point, it’s like a radio advertisement which contains a URL. Interested people can remember it (or note it down), and enter it manually.

But should the alt attribute contain URLs?

Only in one case: if the image shows URLs.

Relevant guidelines (from HTML’s Requirements for providing text to act as an alternative for images):

However, in such a case it might be better to use an alternative to img+alt, which allows using a hyperlink (a).

In your example, the alt attribute should not contain the URL, as it’s not part of the image. The URL might also be interesting for users that don’t read the alt text (as it allows copy-pasting, might contain updates, gives more information about the author, and so on), so the best solution would be to link it next to the image (which the answer already does).

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.