4 ms·
<img src=".." alt=""> Do you mean like that? Empty quotes and it would not be read?
by Teichopsia 9y ago
<img src=".." alt="">
Do you mean like that? Empty quotes and it would not be read?
- robin_reala 9y agoExactly. Every img element should have an alt attribute; those with visual content should have explanatory text in it.
- Teichopsia 9y ago:D I knew that. I'm not that noobish. Let's see. If we use an image that doesn't add anything to the content, one would normally use background-attachment to add an image to say, the hero section. (It seems you edited your comment?) Good to know that the screen reader would try to read the file name if there isn't any alt text in it, I didn't know that. So, in the cases we do need to place an img in the document, then we simple place an empty alt text as in my above comment to tell the screen reader not to read the file name since it is only used for decorative purposes...? Edit: I confused your comment with another one.
- drusepth 9y agoWhat is the value of having an alt attribute if its value is blank? Just to tell someone poking at the source code that, "yeah, I know I'm supposed to have this, and it's intentionally left blank"?
- fold_left 9y agoNo, the reason given was > give it an empty alt attribute to indicate to the screen reader that it shouldn’t try to read out the file name or something
- twhb 9y agoFYI, in HTML5 <img src=".." alt=""> is equactly equivalent to <img src=".." alt>. Value-less attributes become attributes with empty string values at the tokenizer level.