Page 1 of 1

Alt text doesn't show as tooltip in some browsers

Posted: Mon Mar 23, 2009 9:23 pm
by gildionne
/*************************************
Title:gbook
Version:1.6
Author:
Demo:www.gilsbus.ca/gbook/gbook.php
Download:
Website:www.gilsbus.ca

Short description:
Need a gbook modification to allow tooltips to work when you hover over a menu image

*************************************/

The 'alt' text attribute that shows a text message when an image is NOT available, does not trigger the tooltip feature in compliant browsers like Firefox. The solution is to use the 'title' attribute. I find that my version of IE, Firefox and Opera all display the tooltip text when hovering over an image that has the 'title' attribute set.

I have modified my version of gbook to include this attribute, if anyone wishes to try it out.

Posted: Tue Mar 24, 2009 7:16 pm
by Klemen
The standard is to use ALT, title is not required but I guess it won't be hard to add it to the next version, thanks for the note.

Posted: Tue Mar 24, 2009 8:10 pm
by gildionne
Here are two links to www.w3school.com pages which the define the correct use of both the 'alt' and 'title' attributes. It also mentions in the first link that Internet Explorer does not follow the HTML specification and it incorrectly displays the 'alt' text as a tooltip.

http://www.w3schools.com/tags/att_img_alt.asp
http://www.w3schools.com/tags/att_standard_title.asp

The specification is for the 'alt' attribute to display the text only if the image is not available, while the 'title' attribute will always display tooltip text.

I have noticed that if I add a null 'title' attribute (title="") to an 'img' tag that has an 'alt' attribute set (alt="foobar"), no tooltip will be displayed, even in IE7.