What is the use of "alt" attribute in <img>tag? | Sololearn: Learn to code for FREE!


What is the use of "alt" attribute in <img>tag?

I am new in html, help me out please!

1/5/2021 10:25:43 AM


4 Answers

New Answer


When the image is taking too long to load or not loading, the text in alt attribute will display in the screen. alt - - > alternative For example: <img src="image.png" alt="Image"> In case the image.png is not a valid file or still loading the "Image" text will be displayed. For other answer, see this: https://www.sololearn.com/Discuss/1155929/?ref=app


alt is the attribute of <img> tag. This represents the alternative text that shows in place of the image if in case image is not loaded for some reason. Example:- <img src="tree.jpg" alt="This is tree" height=500 width=500 />


The alt tag is not really necessary, but recommended. It is simply an alternate text. If the browser can't recognise the original path of image, it'll look for the alt one.