1. Getting Started
  2. Installation: Preline UI

Accessibility

[role='img'] elements have an alternative text

Screen readers have no way of translating an image into words that gets read to the user, even if the image only consists of text. As a result, it's necessary for images to have short, descriptive and accessible alternative text so screen reader users clearly understand the image's contents and purpose.

If you can't see, all types of visual information, including images, are completely useless unless an accessible text alternative is provided which screen readers can convert into either sound or braille. People with low vision or color-blindness disabilities also require accessible alternative text to varying degrees.

Screen readers cannot convert visual image information to speech or braille in the absence of an accessible text alternative associated with the image.

Fixing the problem

Correct markup solutions

The following four markup examples all pass because each example contains markup rendered as alternative text:

<div id="match">Bananas</div>
<div role="img" aria-labelledby="match" id="pass2"></div>
<div id="hidden-match" style="display:none">Banana bombs</div>
<div role="img" aria-labelledby="hidden-match" id="pass3"></div>
<div role="img" aria-label="blah" id="pass1"></div>
<div role="img" title="title" id="pass4"></div>

Incorrect markup solutions

The following five examples fail the role-img-alt rule because the markup contains no corresponding and meaningful alternative text:

<div role="img" id="violation1"></div>
<div role="img" aria-label="" id="violation2"></div>
<div role="img" alt="blah" id="violation3"></div>
<div role="img" aria-labelledby="no-match" id="violation4"></div>
<div role="img" title="" id="violation5"></div>