Enforce that an img
element contains the alt
prop. The alt
attribute specifies
an alternate text for an image, if the image cannot be displayed.
This rule takes no options
// passes when the img has an `alt`
<img src="foo" alt="nice"/>
// passes when the img has an empty `alt` and role="presentation"
<img src="foo" alt="" role="presentation"/>
// passes when the img is aria-hidden
<img src="foo" aria-hidden="true"/>
// fails when the img doesn't have an `alt`
<img src="foo"/>
// fails when the img has alt="" but no role="presentation"
<img src="foo" alt=""/>
- This document from dequeuniversity.com
- This document from w3.org