<html> <head> <title>first page</title> </head> <body> <img src="tree.jpg" alt="" /> </body> </h | Sololearn: Learn to code for FREE!
+ 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""

12th Jan 2017, 4:15 AM
srikanth katuri
srikanth katuri - avatar
3 ответов
+ 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 ^^ )
12th Jan 2017, 6:07 AM
visph - avatar
+ 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)
12th Jan 2017, 4:36 AM
Phil - avatar
I agree if you want to leave alt blank it will not give any kind of output.
18th Jan 2017, 4:53 PM
P D - avatar