HTML Attributes
HTML alt Attribute
The alt attribute provides alternative text that describes an image when it cannot be displayed or seen.
The alt Attribute
The alt attribute is used on the <img> element (and also on <area> and <input type="image">) to supply a text description of the image. This text is shown if the image fails to load, is read aloud by screen readers, and is used by search engines to understand the image.
Syntax
Syntax: <img src="file.jpg" alt="description of the image">. The value is a short, meaningful text description of what the image conveys.
<img src="intern-team.jpg"
alt="Four interns collaborating around a laptop in an office">| Value | Description |
|---|---|
| Descriptive text | A concise description of the image's meaning or content |
| alt="" | Empty alt marks a purely decorative image so screen readers skip it |
| (omitted) | Discouraged; screen readers may read the file name instead |
For accessibility, describe the purpose of the image, not its appearance. Avoid phrases like "image of" or "picture of" since screen readers already announce that it is an image. Use empty alt="" only for decorative images that add no information.
