Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

HTML How to Make a Website Creating HTML Content Structure the Image Gallery

why we use alt attribute in this statement <img src="img/number01.jpg" alt="">

?

Rune Andreas Nielsen
Rune Andreas Nielsen
5,354 Points

Well alt is used to display text if the picture cannot be shown, it can sometimes be useful to show a text like: "In this picture there is a man fishing". When the picture cannot be seen.

If you don't write anything in the alt="", then no text will be provided. From what i know it is considered good practice, to specify the alt attribute even if no text is inside.

thank u

1 Answer

Lucas Santos
Lucas Santos
19,315 Points

The alt attribute provides alternative information for an image if a user for some reason cannot view it (because of slow connection, an error in the src attribute, or if the user uses a screen reader).

Read more about it HERE