-
Notifications
You must be signed in to change notification settings - Fork 33
An img element must have an alt attribute
Kyle edited this page May 8, 2015
·
1 revision
The alt attribute is used in HTML and XHTML documents to specify alternative text (alt text) that is to be rendered when the element to which it is applied cannot be rendered.
The alt attribute does not always have to literally describe the contents of the image. Keep in mind what would be useful to someone who cannot see the image. The alt attribute is supposed to be an alternative for the image, usually stating its purpose. For example an image of a warning sign should not have alt text “a triangle with a yellow background, black border and an exclamation mark”, but simply “Warning!”—unless, of course, the alt text's purpose is to show what the warning symbol actually looks like.
Unsolved:
<img src="img/example.jpg">
Solved:
<img src="img/example.jpg" alt="My Example">