I’m learning HTML and I’m confused about what the alt attribute is for. Sometimes examples describe what’s in an image, and sometimes they put a website address there. What should alt text actually say, and does it work the same way for video?
What should I put in an image’s alt text?
Answers
Think of alt text as the useful text that stands in for an image when someone can’t see it. Screen readers can read it aloud, and browsers may show it if the image fails to load. Those are related uses, but accessibility is the main reason to write it.
Describe what matters about the image in the context of the page. “Girl wearing a jacket” might be enough for a simple example. If an image is a link, describe where the link goes or what it does, which can explain why an example uses a website address.
Reply to this answer
A handy test is: if the image vanished, what short text would help the reader understand the page? Keep it concise and relevant. You usually don’t need to begin with “image of,” since the image element already tells assistive technology that it’s an image.
Not every image needs a description. If it’s purely decorative and adds no information, use an empty alt value, like alt="", so a screen reader can skip it rather than announce something unnecessary.
Reply to this answer
One small correction: alt is primarily an attribute for images, not a general-purpose description field for video. Video accessibility is usually handled with captions or subtitles, and sometimes a separate text transcript or audio description, depending on what viewers need.
If a video has a poster image, that image can have its own alt text. For a link that contains an image, the alt text should make the link’s purpose clear, not just name the picture.
Reply to this answer
The broken-image case is useful to understand, but don’t write alt text only as a backup for a missing file. A screen reader may use it even when the image displays perfectly. Choose words that carry the image’s important information, rather than listing every visual detail.
Reply to this answer
Add your answer
Answers are reviewed before publication.
Related Discussions