It’s important all images have the attribute for alternative text (alt="") regardless of whether an alternative text is added or not.
A screen reader knows how to handle both an empty alt attribute and one with text. If there is no attribute some screen readers will read the path to the image instead, which will often give no value to the end user.
The alt attribute should typically:
- Be accurate and equivalent in presenting the same content and function of the image.
- No more than a few words are necessary, though rarely a short sentence or two may be appropriate. Try not to exceed 120 characters.
- Not be redundant or provide the same information as text within the context of the image.
- Never use the phrases "image of ...", "picture of ..." or "graphic of ..." to describe the image.
Example:
Code:
<img src="assets/img/ml-001.jpg" alt="Moraine Lake" class="img-fluid">