Element

img

Error Type

Known

Guidelines

Requirement

All img elements have an alt attribute.

Error

img element missing alt attribute.

Short Description

All img elements must have an alt attribute.

Rationale

All images must have alternate text. It's required by people that are unable to view the image.

How To Repair

Add an alt attribute to your img element.

Repair Example

<img src="rex.jpg" alt="a picture of Rex the cat" />

Steps To Check

Procedure

1. Check each img element for the presence of an alt attribute.

Expected Result

1. All img elements have an alt attribute.

Failed Result

1. Add an alt attribute to each img element.

Examples

Pass Examples

img element with an alt attribute.
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta http-equiv="Content-Type" content="text/xhtml; charset=UTF-8" />
<title>Testfile - Check #1 - Negative</title>
</head>
<body>
<p><img src="rex.jpg" alt="A black and brown cat named Rex."/></p>
</body>
</html>

Fail Examples

img element without an alt attribute.
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta http-equiv="Content-Type" content="text/xhtml; charset=UTF-8" />
<title>Testfile - Check #1 - Positive</title>
</head>
<body>
<p><img src="rex.jpg"/></p>
</body>
</html>

English | German | Italiano


Web site engine's code is copyright © 2011
Inclusive Design Institute
Web Service API