La Vita è Bella

Thursday, March 31, 2005

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<img src="http://wang.yuxuan.org/pix/at.png" alt="@" />bar<img src="http://wang.yuxuan.org/pix/dot.png" alt="." />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<img src="http://where/is/my/picture/at.png" alt="@" />bar<img src="http://where/is/my/picture/dot.png" alt="." />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.



tags: , , , ,

18:33:00 by fishy - w3c - Permanent Link

Revision: 1.0/1.0, last modified on 2005-04- 1 @ 09:33.

Karma: 6 (52.31% out of 130 were positive) [+/-]

You can subscribe to RSS 2.0 feed for comments and trackbacks

Trackbacks:
There are currently no trackbacks for this item.
Use this TrackBack url to ping this item (right-click, copy link target). If your blog does not support Trackbacks you can manually add your trackback by using this form.

No comments yet

Add Comment



A blog about open source, patches, thoughts and geeks