How to use the 'alt' attribute with images


#1

Hi All

I would like to display images including the alt tag

So far this seems to come very close

<%= link_to( image_tag(“myimg.png”, { :border => 0, :alt => “bla bla”
}), :action => “config” ) %>

I see the image and no border (which is what I want :), but no alt!!

Any suggestions why ?

Thnx a lot
LuCa

ps Maybe important, I’m using firefox!


#2

According to the RDocs, it looks right to me, so I’ll defer that part to
a more experienced user.

But I do want to ask why you are using curly braces between border and
alt ?? Is there a benefit there that I’m unaware of?

Matt


#3

The curly braces is something I found on the internet. When I remove
them I get the same result ( no alt )

LuCa


#4

So far this seems to come very close

<%= link_to( image_tag(“myimg.png”, { :border => 0, :alt => “bla bla”
}), :action => “config” ) %>

I see the image and no border (which is what I want :), but no alt!!

Works perfectly for me.

What do you mean by saying you see no alt? Did you look for it in
generated HTML,
or do you expect it to show up like little yellow popup(tool-tip) when
hovering mouse
cursor over image? In latter case only IE will show alt attribute as
tool-tip and IE is wrong.
If you still want this tool-tip you should use title attribute, not alt.

If tool-tip is not that you want, then check your code and generated
HTML. With the code you’ve
provided I get:
bla bla - just how
it is supposed to work.

Regards,
Rimantas

http://rimantas.com/


#5

yep, :title attribute is what I need!!

Thnx a lot
LuCa