4 ms·
According to this, if I have <div><img/><span>label</span></div> should the img have aria-labeled-by as well?
by eska 6y ago
According to this, if I have
<div><img/><span>label</span></div>
should the img have aria-labeled-by as well?
- ghusbands 6y agoIt depends. Essentially, the label of the image should be what you would read out to someone in place of the image if you were reading the page out loud. So if the image is of Jerry running away from Tom and the nearby label is "Classic mayhem", then you should instead use an alt-text like "Classic cartoon with Jerry running away from Tom". But if the image is of Tom Hanks accepting an Emmy and the nearby label is "Tom Hanks accepting an Emmy" then an aria-labeled-by with the span's id is fine. Note that this is why an alt-text of "Company logo" is almost never what you want; it isn't what you'd read when reading the page out to someone.
- eska 6y agoI see. I'm using Markdown  So I suppose I can put the title in the <span> and the alt text in the img alt tag, then only use aria-labelledby if no alt text is provided.