Answered by
Oliver Hall
Image alt attributes and aria-label are both used to provide alternative text descriptions for images or elements on a webpage, but they serve different purposes especially when it comes to accessibility and SEO.
The alt
attribute is used inside the <img>
tag in HTML. It provides a text description of what an image is about, which can be read by search engines and screen readers (for visually impaired users). This helps improve the accessibility of your website and also contributes to SEO, as it gives search engines more context about the content of your website.
Here's an example:
<img src='example.jpg' alt='A description of the image'>
ARIA stands for Accessible Rich Internet Applications, and it's a set of attributes that define ways to make web content and web applications more accessible to people with disabilities. The aria-label
attribute is one of these. It provides an accessible name for an element which is used by assistive technology such as screen readers.
One key distinction between aria-label
and alt
is that aria-label
can be used on any element, not just <img>
, while alt
is specifically for images.
Here's an example:
<button aria-label='Close Account'>X</button>
In this case, a screen reader would read out 'Close Account' rather than 'X'.
Overall, both alt
and aria-label
contribute to making your website more accessible, but alt
has an additional benefit of providing SEO value by giving search engines context about your images.