DEV Community

Belhassen Chelbi
Belhassen Chelbi

Posted on

Why is The "alt" attribute so important for images?

Maybe it seems basic, but I remember when I used to ignore this attribute when Writing an image tag. You shouldn't do that for the following reasons:

It is shown when the image doesn't exist [really basic]

Sometimes you copy the link of an image from another site and you put it in the source attribute(src) like this from example

<img src="https://scontent.ftun3-1.fna.fbcdn.net/v/t1.0-

9/23844430_1595292810569743_8608995995175264766_n.jpg?

oh=4ec53eb36555985367848ef693bd824f&oe=5ABD4CDC" >
Enter fullscreen mode Exit fullscreen mode

This is my cover picture of my Facebook profile , and let's I used it in my website, then I want to delete it from facebook, so t would be deleted too in my website, it will give me something like this:

image not found
The user won't even know what the missing is even describing so we need to add the "alt" property like this

<img src="https://scontent.ftun3-1.fna.fbcdn.net/v/t1.0-

9/23844430_1595292810569743_8608995995175264766_n.jpg?

oh=4ec53eb36555985367848ef693bd824f&oe=5ABD4CDC" 

alt="minimal design"> 
Enter fullscreen mode Exit fullscreen mode

this gives this:

minimal design

so it doesn't save your life but at least the users knows what's hidden.

Accessibility matters

"web accessibility means that people with disabilities can use the web"
So, we should work on accessibility when making websites, it's just awesome to provide EQUALITY in this world.

The alt attribute has to be there in the image tag and it should be describing so people with disabilities know what's there with screen readers.
Facebook uses AI to recognize what does the image contain and puts the description automatically in the value of the alt attribute.

For example, this is an image one year ago with two of my friends :

with my friends

in the alt attribute I found : 'Image may contain: 3 people, eyeglasses'. and yeah, the eyglasses are mine. This was auto-generated after the image was being uploaded, and this is awesome, everyone can know what's in there and it will be more awesome if you provide the alt yourself, you the human.

For Search engine optimization sake

Search engine loves alt, that means they want to know information about your image, so they look at alt attribute value; so if you care about SEO, add the alt.
you can learn more basic things about SEO in this youtube playlist course

So yes, alt matters.

Top comments (4)

Collapse
 
meisekimiu profile image
Natalie Martin

The alt attribute is also important for things like logos or other stylized text put into images. It lets machines know what text is in your image which is very useful. Especially when using automatic page translation tools!

Collapse
 
belhassen07 profile image
Belhassen Chelbi

yeah so it's a lot more accessible , I mean you provide an alt in English and it can be translated to whatever language is, this really awesome when you think of it as providing information about an image for people who wan't see it, this is a justice tool.
Thanks for adding your great ideas mate ♥

Collapse
 
jenc profile image
Jen Chan

Just wanted to add it's also accessible because visually impaired users who use screenreaders will have the alt text read out loud when it's in focus, or text-to-speech is on.

Collapse
 
belhassen07 profile image
Belhassen Chelbi

I think I've mentioned the screen readers thing in the accessibility paragraph, thanks fake jen chan lol ♥