Hacker News new | past | comments | ask | show | jobs | submit login

According to this, if I have

should the img have aria-labeled-by as well?

It 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.

I see. I'm using Markdown ![alt text](/src/of/image.jpg "title")

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.

Applications are open for YC Winter 2021

Guidelines | FAQ | Support | API | Security | Lists | Bookmarklet | Legal | Apply to YC | Contact