La Vita è Bella

2005-03-31

The correct way to use "alt" in images

Wanna post your e-mail address at your homepage, but be worried about the spam spiders? You can use a picture, just like what E-Mail Icon Generator do; Or you can use "_AT_" instead of "@", just like "foo_AT_bar_DOT_com". But neither is friendly, easy to use. You must type the email address yourself, you can't just copy & paste it.

So here's a solution for it.

Preparing 2 pictures, one for "@" & one for ".", just like the followings: the picture of the picture of

Now, put them into your e-mail address, replace the real "@" and ".".

I guess you'll say, that don't work. Yep, it don't work, it isn't finished. Remember the title? Our focus is the "alt" attribute. Now, add the "alt" attribute into "img", which content is the one you've replaced: "@" or ".", see the following html code:

foo@bar.com

Here's the effect:

foo@bar.com

Copy it, and paste it to the "To" field in your mail client. If you're using Firefox, you'll get the perfect e-mail address. If you're using ie, unfortunately, you'll only get this: "foobarcom". Stupid ie can only show the stupid tooltip(maybe you should add a title="" to stop ie from showing the stupid tooltip), but not process "alt" correctly. So, you should throw your ie into trash now.

That's not the end. If you're lazy, don't wanna prepare the 2 pictures, just omit the picture thing, like this:

foo@bar.com

See what?

foo@bar.com

Stupid ie will give you a stupid cross, but in Firefox, it's correct and copyable.

Yeah, trash your ie today. Now.

18:33:00 by fishy - Permanent Link

May the Force be with you. RAmen