Skip to content

Latest commit

 

History

History
37 lines (24 loc) · 842 Bytes

img-uses-alt.md

File metadata and controls

37 lines (24 loc) · 842 Bytes

img-uses-alt

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.

options

This rule takes no options

Passes

// 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

// 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=""/>

See also