Alt Attribute Required
ID |
html.alt_attribute |
Severity |
low |
Remediation Complexity |
low |
Remediation Risk |
low |
Remediation Effort |
low |
Resource |
Reliability |
Language |
Html |
Tags |
accessibility, reliability |
Description
Flags an element that conveys an image but provides no alt attribute at all: <img>, <area>, or
an <input type="image">.
Rationale
The alt attribute supplies the text alternative that assistive technologies announce in place of
the image, and that browsers show when the image fails to load. Omitting it entirely leaves
screen-reader users with no idea what the image represents. An explicit empty alt="" is valid and
intentional for decorative images, so only a completely missing attribute is flagged.
<img src="a.png"> <!-- FLAW — no alt attribute -->
<input type="image" src="b.png"> <!-- FLAW — no alt attribute -->
<img src="a.png" alt="A cat"> <!-- OK — descriptive alt -->
<img src="d.png" alt=""> <!-- OK — decorative image -->
Remediation
Add an alt attribute describing the image’s purpose. For purely decorative images that add no
information, use an empty alt="" so assistive technologies can ignore them.