Reputation: 25
Reading google prompt for using alt in internal links (https://support.google.com/webmasters/answer/47334) I looked for answers. I found a bit old thread (Is it correct to use alt tag for an anchor link?) in stackoverflow with reasonable answers that using alt for an anchor link is incorrect. Can someone help me understand better?
Upvotes: 0
Views: 4244
Reputation: 96587
As I explained in the linked question, the a
element can’t have an alt
attribute.
Google’s documentation is not really formulated with sufficient precision:
For example, for your site's internal links, make sure you use anchor text and
alt
text that's informative, compact, and avoids repetition.
While it might be the case that they think of images being part of the anchor text (they should say so!), it could also be the case that they confused alt
with title
(which is an error you’ll often find, for example in this question).
Upvotes: 1
Reputation: 35983
You should use the title attribute for anchor tags if you wish to apply descriptive information similarly as you would for an alt attribute. The title attribute is valid on anchor tags and is serves no other purpose than providing information about the linked page.
W3C recommends that the value of the title attribute should match the value of the title of the linked document but it's not mandatory.
http://www.w3.org/MarkUp/1995-archive/Elements/A.html
Alternatively, and likely to be more beneficial, you can use the ARIA accessibility attribute aria-label
(not to be confused with aria-labeledby
). aria-label
serves the same function as the alt attribute does for images but for non-image elements and includes some measure of optimization since your optimizing for screen readers.
http://www.w3.org/WAI/GL/wiki/Using_aria-label_to_provide_labels_for_objects
If you want to describe an anchor tag though, it's usually appropriate to use the rel or rev tag but your limited to specific values, they should not be used for human readable descriptions.
Rel serves to describe the relationship of the linked page to the current page. (e.g. if the linked page is next in a logical series it would be rel=next)
The rev attribute is essentially the reverse relationship of the rel attribute. Rev describes the relationship of the current page to the linked page.
You can find a list of valid values here: http://microformats.org/wiki/existing-rel-values
Upvotes: 2
Reputation: 53198
The answer provided by Google is a little confusing. The alt
attribute (according to the specification anyway) is not a valid attribute of an a
tag. The only valid attributes for a
elements are as follows:
charset
type
name
href
hreflang
rel
rev
accesskey
shape
coords
tabindex
onfocus
onblur
What the answer really means is as follows:
For example, for your site's internal links, make sure you use anchor text and
alt
text for images that's informative, compact, and avoids repetition.
Upvotes: 4