What Is Alt Text?
Alt text is a short line of text that describes an image on a web page. It is added in the HTML code so screen readers and search engines can understand the picture.
Definition
Alt text, also called alternative text, is the written description inside the alt attribute of an image tag. Its job is to explain what the image shows or means when the picture cannot be seen.
Why Alt Text Matters
- Accessibility People who use screen readers, for example people who are blind or have low vision, rely on alt text to know what each image shows.
- SEO Search engines cannot see images like humans. Alt text tells them what the image is about, which can help your page and your images rank better in search results.
- Broken images If an image does not load, the browser can show the alt text so users still get the meaning.
- Better user experience Clear alt text makes your site more useful and easier to understand for everyone.
How Alt Text Works
In HTML, images use the <img> tag with an alt attribute. The value of this attribute is the alt text. When a screen reader reaches the image, it reads that text aloud. Search engines also read this text to understand the image content and context.
Good alt text is usually short, clear, and specific. It explains the main subject and purpose of the image, not every tiny detail.
Example of Alt Text
Imagine you have a photo of a brown dog running on green grass in a park. Here are examples:
- Poor alt text
alt="dog"(too vague) - Better alt text
alt="Brown dog running on green grass in a city park"
The better version tells the user what kind of dog image it is and what is happening, which is more helpful.
Alt Text vs Image File Name
Alt text is written to describe the image for people and screen readers, and it is stored in the HTML code. Image file name is the name of the image file itself, like brown-dog-park.jpg. Both can help SEO, but alt text is mainly for accessibility and meaning, while the file name helps search engines and file organization.
FAQs
Do all images need alt text
Most important images should have alt text, especially images that add meaning, show products, or explain information. Purely decorative images can use empty alt text, like alt="", so screen readers skip them.
How long should alt text be
Try to keep it short, usually under 125 characters. Focus on the key subject and action of the image.
Should I add keywords to alt text
You can include a keyword if it fits naturally, but do not stuff many keywords. Always write for people first.
What if I do not add alt text
Users who rely on screen readers may miss important information, and search engines may not fully understand your images, which can hurt both accessibility and SEO.