Feed on

HTML5 and Optional Alt Attribute

HTML5 currently allows the alt attribute of the image element to be optional. If an image is given alt=””, it indicates that the image is decorative and does not convey content, or that the content of the image is conveyed elsewhere, such as through an image caption or adjacent text. In HTML5, omitting the alt attribute indicates that an alternative for the image was not provided or cannot be determined. An instance where no alt attribute might be necessary is when a user uploads hundreds of photos to a photo sharing site and will not provide alternative text for each of them. Because the alt attribute is required in previous versions of HTML and XHTML, this would require the photo sharing site to give the images improper alternative text (either alt=””, which is not accurate because the image does convey content, or generic, inaccurate alternative text such as alt=”photo087″ or similar) in order to be valid HTML. In HTML5, the alt attribute may be omitted in this case, and while this does not make the image accessible, this does provide an indication that the image is not accessible and might allow screen readers to then attempt to find or present additional potentially useful information about the image (such as the image file name, results from a related image search, etc.).

3 Responses to “HTML5 and Optional Alt Attribute, 1/30/13”

  1. Laura says:

    The alt attribute is required for valid XHTML and HTML4. For valid HTML5 the requirement was expanded to include either the alt attribute or the figcaption element. You need either one or the other for valid HTML5. From the spec:

    “A conformance checker must report the lack of an alt attribute as an error unless one of the conditions listed below applies:
    The img element is in a figure element that satisfies the conditions described above.”


    • MDTAP Blog says:

      Hi Laura,
      Thank you for your interest in this subject. These tips were created by colleagues at WebAIM. Although I’m not Knowledgeable enough about this subject to respond to your comments, please feel free to contact them with any questions or thoughts on this issue.

  2. Laura says:

    WebAiIM must have been reading a very old draft of the HTML5 specification.

    In addition, the “HTML5: Techniques for providing useful text alternatives” spec details what do when a text alternative is unknown at the time of publication:
    “In some cases an image may be included in a published document, but the author is unable to provide an appropriate text alternative. In such cases the minimum conformance requirement is to provide a caption for the image. The caption must be provided using the figcaption element and the alt attribute. The use of figcaption is recommended over the use of the alt attribute as the figcaption element is designed as a container for caption text, while the alt attribute is designed as a container for a text alternative. In practice the alt attribute has and will continue to provide a more generic method for providing information about an image until such times that the figcaption element is well supported in browsers and assistive technologies.”

Leave a Reply

MDTAP | 2301 Argonne Drive, Room T17 Baltimore, Maryland 21218| Voice: 410-554-9230 Toll Free ⁄ Voice 1-800-832-4827|Email: mdtap@mdtap.org