+ 1
what is the role of alt=""
<img src="tree.jpg" alt="" />
3 Respuestas
+ 4
Hello, Firas Hajji !
The alt attribute sets the alternative text for images. This text allows you to get text information about the image when the download of images is disabled in the browser. Since images are downloaded after the browser receives information about it, the text replacing the picture appears earlier. And already as you load the text will be replaced by the image.
By the way, pay attention to the lesson from SoloLearn.
https://www.sololearn.com/learn/HTML/1030/?ref=app
+ 3
Just wanted to add some... Also it is useful for the accessibility. Blind people using screen readers can get information about images on web-pages. And one more, also this information could be easily acquired and used by some bots/parsers/other types of automation (tools).
+ 1
If the user’s internet connection is slow/nonexistent or something else makes the image not load, alt=““ will display text to describe the image or convey a message such as “The image failed to load.”. For example:
<img src=“Awesome_wolf.jpg” alt=“Awesome wolf pic”
</img>
This will display the image named “Awesome_wolf”, but if the image does not load, the text “Awesome wolf pic” will be displayed instead.
(Wolves are my favorite animal)