requires images to have alt text (img-req-alt
)
Both HTML5 and WCAG 2.0 requires images to have a alternative text for each image.
Rule details
Examples of incorrect code for this rule:
<img>
Examples of correct code for this rule:
<img alt="...">
Options
This rule takes an optional object:
{
"allowEmpty": true,
"alias": []
}
allow empty
Sometimes images are used in context where the image only adds to the user experience but is already clear from an A17Y perspective.
When true
this allows empty <img alt="">
to be used to prevent errors and to
signal that the image is not ment to be read.
Examples of correct code for this rule:
<span>The task was successfully completed! <img src="thumbsup.png" alt=""></span>
alias
If javascript is used to set the attribute on-the-fly (e.g. using
angular-translate
) the alternative attributes can be listed here.
Examples of correct code when alias
is ["data-alt"]
:
<img data-alt="...">