Always think about what an image is for, as well as what’s in it. Images are “inline replaced content”, meaning that they are considered part of the text content, not a structural element like a table, and they are “replaced by” their content. So imagine them as a text sized box containing their alt text, and then replace them with their visual content. In other words, read out an image’s alt text with the text from the nearest block level container. That’ll give you an impression of the context A blind user will experience your alt text in.
Some tips:
- blank alt text is better than no alt text: alt=““ should be fine if the image is pure decoration
- if a photo repeats some text next to it (such as an avatar image beside a user name), it could also be blank, or “User Name’s photo”
- when a company logo links to the home page, an alt text of “Back to hone page” is probably more useful than “Company logo”