Using Alt Text Properly
The alt attribute (short for alternative text) describes the appearance and function of an image inside an HTML document. Using alt text correctly is arguably the most important rule in both Web Accessibility (a11y) and Image SEO.
If an image fails to load, the alt text is displayed on the screen in its place. More critically, screen readers read this text aloud so visually impaired users can understand what the image shows. Search engines also read the alt text to rank your page.
Every single img tag must include an alt attribute, but what you write inside it changes depending on the image's purpose.
1. Informational Images
If an image adds content or context to the page, the alt text must describe the image accurately and concisely. Do not start with "Image of..." or "Picture of..."; the screen reader already announces that it's an image.
2. Functional Images
Sometimes an image acts as a button or a link (like a magnifying glass icon for a search bar, or a social media logo). In this case, the alt text shouldn't describe the image itself, it should describe the action that occurs when you click it.
3. Decorative Images
If an image is purely decorative (like a background pattern, a colored divider, or a stylized flair) and adds no actual information to the page, you must still include the alt attribute, but you should leave it completely empty (alt="").
An empty alt attribute tells the screen reader "This image has no meaning, just skip right past it". If you forget the alt attribute entirely, many screen readers will attempt to read the entire garbled file name out loud.
Full Working Example
Below is a visual representation of how different images demand different types of alt descriptions: