OAA IMAGES_1: Images must have valid alt text.

Details

  • For images that don’t have a presentation role and that can be determined to be non-decorative, determine if the alt attribute is missing.
  • Non-decorative images that convey meaning must have valid alt text.

Rulesets

WCAG 2.0 Requirement 1.1.1 Non-text Content
Status: Accepted
Severity: Violation
Priority: Priority 1
IITAA 1.0 4.1 Provide appropriate "alternate text" for all images.
Type:
Severity: Violation
Priority: Priority 1
Status: Accepted

Markup References

Validation Code

Message

Non-decorative images that convey meaning must have valid alt text.

Dependencies

None

Context

img[@role != "presentation"]

Parameters

  • max_decorative_width : { type: Integer , value: 8 }
  • max_decorative_height : { type: Integer , value: 8 }

Code

function (ruleContext) {
  var vparams = this.validateParams;
  // Don't flag images that are smaller than 9x9 pixels.  
  // If image is greater than 9x9, make sure is has an alt attribute.
  var passed = (ruleContext.clientWidth <= vparams.max_decorative_width.value &&
    ruleContext.clientHeight <= vparams.max_decorative_height.value) ||
    OpenAjax.a11y.xbrowser.hasAttribute(ruleContext, "alt");
  return new ValidationResult(passed, [ruleContext], '', '', []);
} // endfunction