Can anyone describe a scenario where alt atribute can be set to an empty value? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 16

Can anyone describe a scenario where alt atribute can be set to an empty value?

9th Nov 2016, 12:45 PM
//Lana Wilson
//Lana Wilson - avatar
3 Answers
+ 8
When you have an image with only visual value, that is only meant to make the design better but isn't relevant to the content ( like a banner ..etc). It would be better to set it to an empty value, as reading it will be useless.
9th Nov 2016, 12:53 PM
User3827
+ 5
One possible scenario is where you set an image as the background of a block. Having an alt value here could mess up the readability of the content in the foreground. In such situations though, it makes more sense to use css to set the image instead of img element. If the alt attribute isn't required, you probably don't need to use the img element there. There is no hard and fast rule for this though, it's just an aspect of good design to avoid meaningless stuff in your webpage. The final choice however, depends on personal preference.
9th Nov 2016, 1:43 PM
Vignesh Prasad
Vignesh Prasad - avatar
+ 5
vaccuum
22nd Dec 2016, 3:40 PM
nandakishore
nandakishore - avatar