The alt attribute in the <img>
tag is used to describe the content of an image. It is important for several reasons:
- Accessibility: Helps users with screen readers understand what the image depicts.
- SEO: Search engines use the alt attribute to index the content of images, which can improve the visibility of the page.
- Alternative display: If the image cannot be loaded, the alt attribute provides alternative text that is displayed in its place.
Example of using the alt attribute:
<img src="example.jpg" alt="An example image showing a landscape">