Skip to main content

The <img> Element

As defined in the HTML Living Standard, the <img> element represents an image. It is a void element used to embed graphical content into a web page.

Visual Example:

A placeholder image with the text 'Accessible Web Design' in blue over a light gray background.
<img src="path/to/image.jpg" alt="A descriptive summary of the image content"> View HTML Living Standard: The img element

The Essential alt Attribute

The alt attribute provides a text alternative for the image. It is the single most important accessibility feature for visual content.

WCAG Requirement: Non-text Content

Success Criterion 1.1.1 (Level A): All non-text content that is presented to the user has a text alternative that serves the equivalent purpose.

For images that convey information, the alt text should be a concise description of that information. If an image is purely decorative (like a background pattern or a redundant icon), you must still include the attribute but leave it empty: alt="". This tells screen readers to skip the image entirely.

Understand SC 1.1.1: Non-text Content

Modern Performance Attributes

<img src="small.jpg" srcset="large.jpg 1024w, medium.jpg 640w, small.jpg 320w" sizes="(min-width: 1024px) 1024px, 100vw" alt="A scenic view of the ocean" loading="lazy">

Usage Warnings

A11y Tip: Beyond Alt

If an image requires a very long description (e.g., a complex infographic), use the alt attribute for a brief summary and provide the full details in the surrounding text or via a link to a separate description page.