alt
The alt attribute in HTML offers alternative text for images, enhancing web accessibility and boosting SEO. It describes images for users with visual impairments and is displayed when images fail to load.
alt attribute
The alt
attribute in HTML provides alternative text for images, making web content more accessible and improving SEO. It describes images for visually impaired users and displays in place of images that don't load.
Syntax
index.html
<tagname alt="text">
Use the
title
attribute to add a tooltip to an image.Example
here is example to define the alt
attribute:
index.html
<img src="image.jpg" alt="A beautiful sunset over the ocean">
The
alt
attribute can only be used with <input type="image">
elements.Values
- text
- Explanation for alternative text.
Applies To
The alt
attribute can be applied to the following HTML elements.
Conclusion
The alt
attribute in HTML provides a description for images, making content accessible to users with visual impairments and improving SEO. It is displayed when images fail to load, ensuring a better user experience. The attribute can be applied to elements like <img>
, <input>
, and <area>
.