Coastal Media Brand

The alt attribute within an <img> tag provides alternative content for users who can’t download images, or who have images turned off altogether. We use this attribute all the time to make our content more accessible, but have you ever considered what it actually looks like?

We’re going to use the email template we built in a previous tutorial as an example, but the principles apply just as well to browser-based web design.

1
<img src="images/h1.gif" alt="Creating Email Magic" width="300" height="230" style="display: block;" />

If we take a look at our file with images turned off, this is what it looks like:

altTagsBeforealtTagsBefore

Clearly the ALT text is unattractive–especially the links. We can do a few things to jazz it up.

CSS Alt Text

We can add styles to our alt text using CSS. So for the main heading, we’re going to make the text much larger and change it to our dark blue instead of black. We do this by adding styles to the parent element (in this case a cell). These styles will then be applied to the alt tags within that cell.

This is our cell:

1
<td align="center" bgcolor="#70bbd9" style="padding: 40px 0 30px 0;">
2
 <img src="images/h1.gif" alt="Creating Email Magic" width="300" height="230" style="display: block;" />
3
</td>

We’ll add some text styling so it looks like this:

1
<td align="center" bgcolor="#70bbd9" style="padding: 40px 0 30px 0; color: #153643; font-size: 28px; font-weight: bold; font-family: Arial, sans-serif;">
2
 <img src="images/h1.gif" alt="Creating Email Magic" width="300" height="230" style="display: block;" />
3
</td>

And we’ll style our social media links so that they become white:

1
<table border="0" cellpadding="0" cellspacing="0">
2
 <tr>
3
  <td style="font-family: Arial, sans-serif; font-size: 12px; font-weight: bold;">
4
   <a href=" style="color: #ffffff;">
5
    <img src="images/tw.gif" alt="Twitter" width="38" height="38" style="display: block;" border="0" />
6
   </a>
7
  </td>
8
  <td style="font-size: 0; line-height: 0;" width="20">&nbsp;</td>
9
  <td style="font-family: Arial, sans-serif; font-size: 12px; font-weight: bold;">
10
   <a href=" style="color: #ffffff;">
11
    <img src="images/fb.gif" alt="Facebook" width="38" height="38" style="display: block;" border="0" />
12
   </a>
13
  </td>
14
 </tr>
15
</table>
altTagsAfteraltTagsAfteraltTagsAfter

Conclusion

Simple as that! Now we can be confident that our email will display well, even with images turned off.

Learn More

Web Design Myrtle Beach

Coastal Media Brand

© 2024 Coastal Media Brand. All rights Reserved.