Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Tags:

html

tooltip

tags

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?

like image 488
Diego Avatar asked Sep 07 '10 12:09

Diego


People also ask

How do I add tooltip to IMG tag?

Use document. getElementById('theImage'). title='tooltip text' .

What attribute goes inside the IMG tag?

The <img> tag has two required attributes: src - Specifies the path to the image. alt - Specifies an alternate text for the image, if the image for some reason cannot be displayed.

Which attribute is used to specify the tooltip of an image file?

Tip: To create a tooltip for an image, use the title attribute!

How do I add an image to a tag?

Images can be easily inserted at any section in an HTML page. To insert image in an HTML page, use the <img> tags. It is an empty tag, containing only attributes since the closing tag is not required. Just keep in mind that you should use the <img> tag inside <body>…


1 Answers

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.

like image 169
David Hedlund Avatar answered Nov 22 '22 03:11

David Hedlund