I was reviewing the HTML5 specification and read sections regarding alternate text for images (using the "alt" attribute):
https://html.spec.whatwg.org/multipage/images.html#alt
It's not as easy as it might seem. There are cases when it should be an empty string, when it shouldn't, and when the "alt" attribute should be left out completely (rare).
I think it should also be stressed that "alt" text is replacement text for the image, not supplemental text, like what can be provided with the "title" attribute.
It should not repeat prose that is right next to it (in this case alt="" may be appropriate).
The "alt" attribute should only be omitted when no alternative text is available and none can be made available. Omitting the "alt" attribute is different than alt="", where the alternative text is an empty string.
There are good examples as well. I would suggest reviewing that section of the specification (4.8.1.1).
Also, keep in mind that using good alternative text may also help with SEO.
What's the right alt text to use? (alternative text)
- Albert Wiersch
- Site Admin
- Posts: 3785
- Joined: Sat Dec 11, 2004 9:23 am
- Location: Near Dallas, TX
- Contact:
What's the right alt text to use? (alternative text)
Albert Wiersch, CSS HTML Validator Developer • Download CSS HTML Validator FREE Trial
- MikeGale
- Rank VI - Professional
- Posts: 726
- Joined: Mon Dec 13, 2004 1:50 pm
- Location: Tannhauser Gate
Re: What's the right alt text to use? (alternative text)
Useful section.
Thanks.
I find that an empty alt string isn't that uncommon.
The suggestion that you put in there what you would say if you were "reading the page out" over the phone, seems like good advice to me.
Thanks.
I find that an empty alt string isn't that uncommon.
The suggestion that you put in there what you would say if you were "reading the page out" over the phone, seems like good advice to me.
- RSteinwand
- Rank VI - Professional
- Posts: 596
- Joined: Mon Jun 09, 2008 2:12 pm
- Location: Fargo, ND
- Contact:
Re: What's the right alt text to use? (alternative text)
Looks like I've got some work to do. I always have an alt with images, but sometimes I've set it to alt="".
Rick
Re: What's the right alt text to use? (alternative text)
This is a great guide on alt text:
https://www.w3.org/WAI/tutorials/images/decision-tree/
https://www.w3.org/WAI/tutorials/images/decision-tree/
- RSteinwand
- Rank VI - Professional
- Posts: 596
- Joined: Mon Jun 09, 2008 2:12 pm
- Location: Fargo, ND
- Contact:
- RSteinwand
- Rank VI - Professional
- Posts: 596
- Joined: Mon Jun 09, 2008 2:12 pm
- Location: Fargo, ND
- Contact:
Re: What's the right alt text to use? (alternative text)
My plan is to use a good description for alt and hope that bots are smart enough to take it from there.
Rick
- Albert Wiersch
- Site Admin
- Posts: 3785
- Joined: Sat Dec 11, 2004 9:23 am
- Location: Near Dallas, TX
- Contact:
Re: What's the right alt text to use? (alternative text)
I think the best thing you can do right now for SEO and alt tags is to write them first and foremost for human readers. Like Rick says, the bots, especially Google, are pretty smart these days and trying to "trick" them or write for them (bots) instead of for people will probably not get you anywhere and could even get you penalized. I think it has been this way for a few years now.
Albert Wiersch, CSS HTML Validator Developer • Download CSS HTML Validator FREE Trial
- Albert Wiersch
- Site Admin
- Posts: 3785
- Joined: Sat Dec 11, 2004 9:23 am
- Location: Near Dallas, TX
- Contact:
Re: What's the right alt text to use? (alternative text)
Here's a good article about alt text when emotion matters (and context too):
https://jakearchibald.com/2021/great-alt-text/
Albert Wiersch, CSS HTML Validator Developer • Download CSS HTML Validator FREE Trial