Tuesday, November 27, 2007

Alternate text for images for different browsers


To show any picture or image on the webpage either img tag is used or <asp:Image> tag is used. We also put some alternate text for the image. Alternate text can be used to show some details on the screen related to the image. Alternate text is displayed when mouse is over the image. Internet explorer shows a cross sign which means that image is not available on the server where FireFox shows the alternate text on the screen instead of cross sign.

To show alternate text on the image we use
"alt" attribute for img tag .
"Alternatetext" attribute for asp:Image.

But the funny side of these attributes is they are not supported by Firefox. If you use any of these attribute to show alternate text then alternate text is not displayed in Firefox.

After some hard work I found a common solution which is supported by most browsers. Solution is to use " title" attribute instead of "alt" attribute. This attribute is supported by all the browsers.
<img src="sunset.jpg" title="Image1"> </img>

So if you are making an application for different browser stop using alt attribute and switch to title attribute.

Enjoy.

2 comments:

Anonymous said...

Where do u work ?

Virendra said...

I work with a software company in india.

back to top