+ 1
<html> <head> <title>first page</title> </head> <body> <img src="tree.jpg" alt="" /> </body> </h
in this code what's the use of alt""
3 Answers
+ 3
Html5 recommendation say that <img> tag require the use of alt attribute, even it's with an empty value, because this attribut is not only a way to describe the picture content if doesn't load, but mostly a way for describe to blind and other people who can't access to it, as well as be robot better understanable ;) ( see MDN -- Mozilla Developer Network - reference site web for more precisions ^^ )
+ 2
if I remember right, alt is the text that shows up if the picture doesn't load. I'm not sure why you would leave it blank though - perhaps to come back to it later, or maybe an IDE automatically put it in and the dev just hasn't changed it, or maybe to prevent an IDE from nagging that the img tag lacks an alt (some ides nag you if you try to save html that is considered bad practice)
0
I agree if you want to leave alt blank it will not give any kind of output.