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 Add Social Media Links

what is alt text?

What is alt text? I'm being told that I need to add it to the code for the twitter image.

index.html
<!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>&copy; 2013 Nick Pettit.</p>
    </footer>
  </body>
</html>
Austin Haugen
Austin Haugen
5,435 Points

Hey 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.

Miroslav Kovac
Miroslav Kovac
11,454 Points

Alt 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.

the '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

Hi,

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

I 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
Cody Care
88 Points

I'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.