"16x16", :alt => "D...">

Alt text does not appear when hovering over image

I have the following code:

<td><%= link_to(image_tag("delete.gif", :size => "16x16", :alt => "Delete Entry"), phone, :confirm => 'Are you sure?', :method => :delete, :remote=>true, :class=>'delete_phone') %></td> 

in my opinion. Now everything works fine and does what I need, but when I hang over the icon, well, it does not show me any text. I tried in Firefox and Chrome.

Does anyone else face the same issue?

Thanks!

+7
source share
5 answers

#protip - this can be a painful (and not very dry) exercise to add a title to all of your images. To make this a lot less painful, all my applications come with this JS ( jquery required):

 $(function() { $('img').each( function() { var o = $(this); if( ! o.attr('title') && o.attr('alt') ) o.attr('title', o.attr('alt') ); }); }); 

This sets the title any img without title for the value of the alt attribute.

+11
source

Use a name, not alt, and your problems will be solved! Alt is for access - it means "alternative." The name is what you would use for a tooltip.

+10
source

I have no idea about Ruby, but you need to use the title attribute in HTML to get the rollover text that appears in most browsers. Does it help at all?

eg

 <img title="hello thar" src="hellothar.gif" /> 
+7
source

When you hover over the title image, the text appears in the tooltip.

Alt text is intended for users with disabled images (or slow connection) and search engines

+6
source

Use the title option to display text in rails 3.

 <%= image_tag 'Profile.png',:title => 'Profile' %> 

When the mouse hovers over Profile.png , it will display the text Profile .

+4
source

All Articles