Alt text is a description of an image that cannot be seen by a sighted user but is available to blind users via screen readers.
When it comes to the web accessibility principles, the inclusion of an alt attribute with an image in HTML code needs to be at the forefront of the developers’s mind. They provide for a rich user experience for every visitor to your site by offering the content of the image in a text-based format. If you don’t provide alt text, then a screen reader will only to say
IMAGE or provide a useless file name.
How Long Is Too Long?
When creating alt text in your code, it is important to remember that these descriptions should be kept short. The longer the text, the more difficult it is for the screen reader and the browser to read it. I have on occasion found myself typing extremely long descriptions of images, including every artistic detail contained within it.
While this could be commended, it may not be helpful. Remember to provide a description that is useful in the context of the document and keep the word count short in the range of 5 to 15 words. You may be able to skip over purely decorative images, but those that have significant information need to have this information spelled out in the alt text.
When it comes to images that have only been included for aesthetic purpose and which serve no purpose other than enhancing the mood of the page we still need to include an alt attribute. In this case the attribute can be empty (alt=””).
In general, alt text should be kept short. However, some images might be so complex that extra information needs to be provided. In these cases, it may be beneficial to repeat the description in a text-based format below the image so that all users benefit from the information.
If I could give any additional words of wisdom they would be not to overthink alt text. It should really just be a simple sentence that adds to the content of your website. By including it in your code, you are demonstrating that you are an inclusive developer, one who wants your content to be available to everyone.
Free Developer Resources
Join over 3,700 subscribers on my weekly web accessibility email and get free developer resources like WCAG Checklists and special offers.
Over 600 developers like you have learned more about the Web Content Accessibility Guidelines with my guidebook.