ALT or TITLE attributes for images — when to use what
The question about when to use the ALT or the TITLE attribute is as old as the markup itself. And still, 13 years since my HTML debut I, myself struggle to get it right. So for me and for everyone else who find it embassising to not be 100% sure about the attributes, I’ve made this quick list.
When to use the ALT attribute
- The ALT attribute is designed to be an alternative text description for images.
- Google use the ALT attribute to determine what an image is about so it´s good for SEO.
- ALT text displays instead of the image in text-based browsers like Lynx or if a image file is missing.
- ALT is a required element for images for valid HTML
When to use the TITLE attribute
- Text contained within the title attribute is used to display additional information.
- Put the title attribute on the <a> tag when you want to describe a link that is only reachable if the visitor clicks on the image.
- Use a TITLE attribute if you want to show the text when the visitor hovers above an image.