Reputation: 3
I have used the ALT tags for all my images with this format:
<a alt="IMAGE ALT TEXT" href="http://2.bp.blogspot.com/-MEHRDQvoG-c/Ux0mL1mlJII/AAAAAAAAGg8/S9h3KjhJ6YQ/s1600/jquery-lightbox-with-dark-background.png" imageanchor="1"><img src="http://2.bp.blogspot.com/-MEHRDQvoG-c/Ux0mL1mlJII/AAAAAAAAGg8/S9h3KjhJ6YQ/s320/jquery-lightbox-with-dark-background.png" style="height:100%; width:100%;" /></a>
But I was surprised when the image checker tools sensed their alt tags as "missing". I supposed I had to insert the "alt" tag after the "img src" tag like that:
<a href="http://2.bp.blogspot.com/-MEHRDQvoG-c/Ux0mL1mlJII/AAAAAAAAGg8/S9h3KjhJ6YQ/s1600/jquery-lightbox-with-dark-background.png" imageanchor="1"><img src="http://2.bp.blogspot.com/-MEHRDQvoG-c/Ux0mL1mlJII/AAAAAAAAGg8/S9h3KjhJ6YQ/s320/jquery-lightbox-with-dark-background.png" alt="IMAGE ALT TEXT" style="height:100%; width:100%;" /></a>
Tell me please will this style correct?
Upvotes: 0
Views: 3572
Reputation: 1032
You may be confusing the "alt" tag and the "title" tag.
The "alt" tag is used with images:
<img src="someImage.jpg" alt="image">
The title tag can be used with BOTH images and links
<img src="someImage.jpg alt="image" title="Some Image">
<a href="someLink.com" title="This is some link">
There wouldn't be any need for an "alt" tag on a traditional link, because even if the link was bad, there would still be text wrapped in the anchor indicating what it is:
<a href="someLink.com">Link to some link</a>
With the image, the "alt" property value only displays when the image, for whatever reason, isn't available.
Upvotes: 1
Reputation: 60563
the alt
should be only used in <applet>, <area>, <img>, <input>
alt -
<applet>, <area>, <img>, <input>
- Alternative text in case an image can't be displayed.
here is a snippet of img
:
<img src="http://lorempixel.com/100/100" alt="image">
Upvotes: 0
Reputation: 395
The alt attribute must be on the element and not on the hyperlink element.
Upvotes: 1
Reputation: 6669
alt is a property of IMG tag and not of A tag. It stands for alternative text to be shown or read by screen readers. So the second example you provided is the right one.
Upvotes: 1