I’d like to know the difference between title attr of the tag "a" and alt attr of the tag img.
Also, which should I use when I have an image inside an a? Just like in this case:
<a class="duplicar" href="#"><img src="Images/btnSegDuplicar.gif" alt ="Duplicar" width="76" height="20" /></a>
Right now, as you can see, I’m using the alt but I’m having a little issue. No matter the browser in my development server the tooltips is shown, but in my production server it is not. I tried using both of them (alt and title) and it worked, but it is kind of ugly. Why is that difference between both servers?
You should always use the
titleattribute for tooltips. With images as well as with anchors.The
altattribute is solely for the purpose of displaying a text when the image can not be viewed for some reason. That this text is sometimes shown as a tooltip is an incidental artifact of some implementations, and by no means a part of its specification.