Brent Brent - 2 years ago 81
Ruby Question

How can I display simple tooltips on icons in html?

I am using ActiveScaffold in a Ruby on Rails app, and to save space in the table I have replaced the default "actions" text in the table (ie. "edit", "delete", "show") with icons using CSS. I have also added a couple of custom actions with action_link.add ("move" and "copy").

For clarity, I would like to have a tooltip pop up with the related action (ie. "edit", "copy") when I hover the mouse over the icon.

I thought I could do this by adding a simple "alt" definition to the tag, but that doesn't appear to work.

Can somebody point me in the right direction?

Answer Source

The alt attribute is to be used as an alternative to the image, in the case of the image missing, or in a text only browser.

IE got it wrong, when they made alt appear as a tooltip. It was never meant to be that.

The correct attribute for this is title, which of course doesn't do a tooltip in IE.

So, to do have a tooltip show up in both IE, and FireFox/Safari/Chrome/Opera, use both an alt attribute and a title attribute.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download