Answered by
Oliver Hall
Yes, decorative images should have alt text, but the alt attribute can be left empty (e.g., alt=""
). This is because screen readers, used by visually impaired users, will skip over images with an empty alt attribute, streamlining their experience by not mentioning irrelevant decorative imagery.
Here's an example of how to use it in HTML:
<img src="decorative-image.jpg" alt="">
Despite being purely decorative, these images still convey a sense of context or mood. Visually impaired users won't miss important content without acknowledging these images, but acknowledging every decorative image can disrupt the flow of content.
However, if the decorative image carries meaningful content or contributes to the understanding of other content, it should have appropriate alt text. For example, if you have an infographic image that adds value to the content, even though it might seem decorative, it needs descriptive alt text:
<img src="infographic.jpg" alt="An infographic showing the growth of renewable energy sources from 2005 to 2023">
Remember, using appropriate alt attributes not only improves accessibility but is also a good SEO practice as it provides search engines more context about your page.