The alt and title attributes provide additional information about images, improving accessibility, SEO, and user experience.
1️⃣ alt (Alternative Text)
- Provides a text description of the image.
- Purpose:
- Displayed if the image fails to load.
- Screen readers use it for visually impaired users.
- Helps search engines understand the image.
Example:
<img src="logo.png" alt="Company Logo">
2️⃣ title (Tooltip Text)
- Provides additional info shown as a tooltip when hovering over the image.
- Mainly for user experience, not critical for accessibility.
Example:
<img src="logo.png" title="This is the company logo">
Combined Example
<img src="logo.png" alt="Company Logo" title="Click here to go to homepage">
alt→ used by screen readers and when image cannot loadtitle→ shows extra info on hover
💡 In Short:
altensures accessibility and SEO by describing the image, whiletitleenhances UX by showing extra info on hover.