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 trialJurrell Walker
Courses Plus Student 237 Pointswhat is alt text?
What is alt text? I'm being told that I need to add it to the code for the twitter image.
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Nick Pettit</title>
</head>
<body>
<header>
<a href="index.html">
<h1>Nick Pettit</h1>
<h2>Designer</h2>
</a>
<nav>
<ul>
<li><a href="index.html">Portfolio</a></li>
<li><a href="about.html">About</a></li>
<li><a href="contact.html">Contact</a></li>
</ul>
</nav>
</header>
<section>
<ul>
<li>
<img src="img/numbers-01.jpg" alt="">
</li>
<li>
<img src="img/numbers-02.jpg" alt="">
</li>
<li>
<img src="img/numbers-06.jpg" alt="">
</li>
</ul>
</section>
<footer>
<img src="img/facebook-wrap.png" alt="">
<img src="img/twitter-wrap.png" alt="">
<p>© 2013 Nick Pettit.</p>
</footer>
</body>
</html>
Miroslav Kovac
11,454 PointsAlt text is displayed if the browser has disabled option to showing the images, or the image cannot be displayed (incorrect path to image). So, in place of image, the alt text makes the alternate description.
abdulrazak awali
4,793 Pointsthe 'alt' attribute allows a user to see a text description if FOR ANY REASON THE IMAGE DOES'NT APPEAR sometimes people turn images off in their browser so adding 'alt' will provide a text inside of nothing
<img src="img/twitter-wrap.png" alt="twitter-image">
now if image is turn off they will see twitter-image
3 Answers
Rich Bagley
25,869 PointsHi,
The alt
tag contains text describing the image that is displayed if the image doesn't show for any reason.
Here's the info from w3schools which may help you with further information.
Hope that helps :)
-Rich
Todd Redmond
8,422 PointsI just wanted to add that the alt text can be important for search engine optimization or simply, your site may show up higher if you include the alt tags. However Google changes what is important often, so it could become more or less important in the future.
Cody Care
88 PointsI'm super late to this party, but alt text is incredibly important for accessibility. Blind users in particular require it to know what's going on on screen.
Austin Haugen
5,435 PointsAustin Haugen
5,435 PointsHey Jurrell -- alt text is shown in place of the image if for some reason the image can't be shown. Sometimes when you load a website, the images don't appear (maybe you are on a slow internet connection, maybe the website developer accidentally deleted the image, if you open up an email that contains images in Gmail sometimes it won't show images by default - you have to click to see them). In the case where the image does not render on the webpage, the browser can detect that the image isn't being shown, and it will display the alt text in the area where the image should be.
There are also special tools for blind people which will actually read the content of a webpage out loud to them. If you have provided alt text the tool will read this text aloud when it gets to the image.
While it is not strictly necessary in the real world to provide alt text, it is a best practice.