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 Build the Footer

what does alt="twitter logo" stands for

i want to know the function of alt in img

Mozilla's definition: This attribute defines the alternative text describing the image. Users will see this displayed if the image URL is wrong, the image is not in one of the supported formats, or if the image is not yet downloaded.

My note - alt is not required BUT (emphasis) it is good practice to use for disabled viewers.

Happy coding- Graham

2 Answers

Jake Lundberg
Jake Lundberg
13,965 Points

It is alternate test that is displayed in the image's place when it does not load for some reason (like if the image file could not be found). It is also used by Screen Readers for visually impaired users that cannot see the actual image. As Graham Tucker said above, it is not required, but it is a good idea to include in your code.

Peter Campbell
Peter Campbell
18,085 Points

An alt attribute is needed on all images to validate your html code. This doesn't mean it won't work without it but it is good practice.

It is useful if someone who is visually impaired visits your site and they are using a screen reader. The screen reader will read the contents of the alt attribute when it gets to the image. If the image is something that wouldn't aid a visually impaired person's understanding of the site, it can be left blank, like this,

<img src="background.jpg" alt="">