alt
The a
element can’t have an alt
attribute.
alt
is for providing alternative text for an image that can’t be loaded/perceived, so it wouldn’t make sense to use it for a hyperlink.
Attributes for a
that can be relevant for accessibility
(Leaving technical things like using the correct dir
, or adjusting tabindex
if needed, aside.)
title
For title
, the general rules for the title
attribute apply: You can use it for advisory information, but don’t rely on it.
The spec gives an example how it can be used for links:
On a link, this could be the title or a description of the target resource
For example, you could have a link with the anchor "my website" and a title
that gives the website’s title:
… <a href="http://example.com/" title="John’s blog | Example">my website</a> …
It can be useful to get this additional information (e.g., it might save the visitor a click, for example because they already know this site by its title), but it’s not a problem if it’s not there (or if the visitor doesn’t notice that it’s there or if the visitor can’t access it).
hreflang
The hreflang
attribute should be used if the target is in a different language than the document you are linking from.
… <a href="http://de.example.com/foo" hreflang="de">German translation</a> …
A user agent could announce/warn, offer to translate, etc.
lang
If the link anchor text is in a different language than the rest of the document, you should use the lang
attribute. If the target is also in this (or another) language, use hreflang
in addition.
… German translation: <a href="http://example.com/de/hallo-welt" lang="de" hreflang="de">Hallo Welt</a> …
A user agent (e.g., a screen reader) could use the corresponding language module for reading it.
type
The type
attribute should be used if the target is not a HTML document, e.g., for PDFs, MP3s, etc.
… <a href="http://example.com/foo.ogg" type="audio/ogg">Download OGG</a> …
A user agent could warn, or open it in a different context, etc.
rel
The rel
attribute is used to specify link types. Most link types don’t play a special role for accessibility, but there might be some (depending on your link purpose).
For example, it’s conceivable that the external
link type (example) could be relevant (a user agent might decide to open these links in a different context), or the help
link type (a user might offer a quick way to open these links), etc.
… <a href="http://example.com/help" rel="help">Help</a> …
accesskey
The accesskey
attribute can be used to associate a keyboard shortcut for visiting the link. But this should only be done in very specific cases (e.g., for a page’s primary link of a link aggregator site).
title
attribute is mostly useless. It doesn't provide the accessibility benefits it is claimed. Screenreaders read out the link target content, you have to enable them to read 'Title' attributes, which people don't do because it just duplicates information read out. And keyboard users don't see them at all because they only show on hover. So the only peopletitle
benefits are fully sighted people who hover their mouse cursor over things. And if you're having to rely on those items to understand where links go then the issue is more in the wording of the link itself than thetitle
.