The alt attribute is used for image accessibility.
✅ alt Attribute
<img src="logo.png" alt="Company logo">
🧠 Why alt Is Important
- Screen readers read the alt text for visually impaired users
- Displays text if the image fails to load
- Helps search engines understand the image
- Required for WCAG accessibility compliance
📌 How to Use alt Correctly
✔ Informative image
<img src="submit.png" alt="Submit button">
✔ Decorative image
<img src="line.png" alt="">
(empty alt tells screen readers to ignore it)
❌ Bad practice
<img src="chart.png" alt="image">
(does not describe anything)
🎯 Short Interview Answer
The
altattribute is used for image accessibility. It provides alternative text for screen readers and is shown when images fail to load, making content accessible to visually impaired users.
⭐ One-line summary
The alt attribute makes images accessible to screen readers and assistive technologies.