Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

Not the OP, but I'd just wrap it up like this:

  <div aria-role="img" aria-label="{your alt-text here}">
    <pre>...</pre>
  </div>
A simple approach is best. I don't have a screenreader on my current machine (as far as I know) so I can't verify actual behaviour right now, but according to MDN:

> ...most screenreaders will consider the element with role="img" set on it to be to be like a black box, and not access the individual elements inside it.

(https://developer.mozilla.org/en-US/docs/Web/Accessibility/A...)



Neat! I'll make sure to do it this way. That makes me wonder, what else on the websites I (not a web dev) maintain might need special treatment for accessibility. Pity the Chrome dev tools don't seem to help with that.




Consider applying for YC's Winter 2026 batch! Applications are open till Nov 10

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

Search: