开发者

Tooltip of an "img tag" inside an "a tag"

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 title attribute for tooltips. With images as well as with anchors.

The alt attribute 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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜