The CSS background image conveys information and is missing text alternative for assistive technology users.

Link to The CSS background image conveys information and is missing text alternative for assistive technology users. copied to clipboard
Rule ID:
alt-text-missing-background-image
User Impact:
Critical
WCAG:
1.1.1.e

Rule

The alternative text for informative or actionable CSS images MUST be available as programmatically-discernible text in the HTML content.

Background

People who are blind cannot see images on a page. In order to give people who cannot see an image access to the information conveyed by the image, it must have a text alternative. The text alternative must describe the information or function represented by the image. Screen readers can then use the alternative text to convey that information to the screen reader user.

CSS background images cannot have an alt-attribute applied directly. However, if it is necessary to do so, you can add alternative text to informative and actionable CSS images using an aria-label.

It is important to note that elements must have semantic meaning in order to receive an aria-label. Elements with semantic meaning include <img>, <a>, and <h1>, because their tags tell you about what they contain. Elements like <span> and <div> are not semantic elements because they could contain many types of content. To give an aria-label attribute to a non-semantic element, you must also give it a role, e.g. role="img", thereby giving it semantic meaning.

Code Examples

alt-text-missing-background-image

Good Examples:

CSS image as a link has an aria-label:

<a href="http://www.facebook.com/dequesystems" class="fb" aria-label="Deque's Facebook page"></a>
<h4>CSS image has an aria-label:</h4>
<pre><code>&lt;span class="fbicon" <span class="highlight">role="img" aria-label="Facebook"</span>&gt;&lt;/span&gt;</code></pre>
<p>Note: It is important to note that elements like &lt;span&gt; and &lt;div&gt; are not semantic elements because they could contain many types of content. To give an aria-label attribute to a non-semantic element, you must also give it a role, e.g. role="img".</p>

Failure Examples:

Alt on a span tag (span tags cannot have an alt-attribute):

<span class="fbicon" role="img" alt="Facebook"></span>
<h4>Functional CSS image has no alt:</h4>
<pre><code>&lt;a href="http://www.facebook.com/dequesystems" class="fb"&gt;&lt;/a&gt;</code></pre>

References