Why to specify the alt value in the img tag?

 Posted by Raja on 3/5/2009 | Category: HTML 5 Interview questions | Views: 4328

alt stands for alternate this means that for some reason if image can't be loaded on the page, the alt value will be displayed.

<img src="myimage.jpg" alt="this is my photo" title="click to go to my page" />

In the above code snippet when myimage.jpg is available on the web server, the image will be displayed and mouse ever on the image will show "click to go to my page" but in case myimage.jpg is not available on the server or by some reason it could't be rendered on the page, alt value (this is my photo) will be displayed in place of image. This hints the user that the picture that couldn't be loaded was my photo.

Asked In: Many Interviews | Alert Moderator 

Comments or Responses

Login to post response