In the last challenge, you learned that including analtattribute when usingimgtags is mandatory. However, sometimes images are grouped with a caption already describing them, or are used for decoration only. In these cases,alttext may seem redundant or unnecessary.
When an image is already explained with text content or does not add meaning to a page, theimgstill needs analtattribute, but it can be set to an empty string. Here's an example:
<imgsrc="visualDecoration.jpeg"alt="">
Background images usually fall under the 'decorative' label as well. However, they are typically applied with CSS rules, and therefore not part of the markup screen readers process.
Note:For images with a caption, you may still want to includealttext since it helps search engines catalog the image's content.
Camper Cat has coded a skeleton page for the blog part of his website. He's planning to add a visual break between his two articles with a decorative image of a samurai sword. Add analtattribute to theimgtag and set it to an empty string. (Note that the imagesrcdoesn't link to an actual file - don't worry that there are no swords showing in the display.)
<h1>Deep Thoughts with Master Camper Cat</h1>
<article>
<h2>Defeating your Foe: the Red Dot is Ours!</h2>
<p>To Come...</p>
</article>
<img src="samuraiSwords.jpeg" alt="">
<article>
<h2>Is Chuck Norris a Cat Person?</h2>
<p>To Come...</p>
</article>