4.8.1 The img element

ISSUE-30 (longdesc) blocks progress to Last Call

Categories
Flow content.
Phrasing content.
Embedded content.
If the element has a usemap or longdesc attribute: Interactive content.
Contexts in which this element can be used:
Where embedded content is expected.
Content model:
Empty.
Content attributes:
Global attributes
alt
longdesc
src
usemap
ismap
width
height
DOM interface:
[NamedConstructor=Image(),
 NamedConstructor=Image(in unsigned long width),
 NamedConstructor=Image(in unsigned long width, in unsigned long height)]
interface HTMLImageElement : HTMLElement {
           attribute DOMString alt;
           attribute DOMString src;
           attribute DOMString longdesc;
			 attribute DOMString useMap;
           attribute boolean isMap;
           attribute unsigned long width;
           attribute unsigned long height;
  readonly attribute unsigned long naturalWidth;
  readonly attribute unsigned long naturalHeight;
  readonly attribute boolean complete;
};

An img element represents an image.

The image given by the src attribute is the embedded content, and the value of the alt attribute and the content referenced by the longdesc attribute is the img element's fallback content.

The src attribute must be present, and must contain a valid non-empty URL potentially surrounded by spaces referencing a non-interactive, optionally animated, image resource that is neither paged nor scripted.

Images can thus be static bitmaps (e.g. PNGs, GIFs, JPEGs), single-page vector documents (single-page PDFs, XML files with an SVG root element), animated bitmaps (APNGs, animated GIFs), animated vector graphics (XML files with an SVG root element that use declarative SMIL animation), and so forth. However, this also precludes SVG files with script, multipage PDF files, interactive MNG files, HTML documents, plain text documents, and so forth.

The requirements on the alt attribute's value are described in the next section.

The longdesc attribute may be present, and must contain a valid non-empty URL potentially surrounded by spaces referencing a separate document, a content fragment in a separate document or content fragment within the same document as the image.

Content referenced by the longdesc attribute, if present, should be exposed by the user agent via a device independent mechanism. The user should be allowed to make a decision on whether to access the content referenced by the longdesc.

For example, a user agent may provide access to the document or document fragment referenced by the longdesc attribute in a context menu associated with the image. In this case the context menu should be operable using the keyboard and a visible indication of longdesc presence should be provided. It is recommended that the image itself be included in the default tab order to provide access to the associated context menu. The option to disable visible indication and access may be provided via a user preference.

Example of longdesc exposed via a context menu (implemented in Opera)

Context menu, displayed over an image, containing a 'long description' menu item.

Another example is to provide an indication of the presence of a description via a programmatically associated visible button or link. The button associated with the image must be included in the default tab order of the document. The button may be hidden until an image is moused over or receives keyboard focus, then user agents should provide a visual indication and mechanism to access the associated description. Clicking on the button or pressing a key when the button has focus will navigate to the referenced content or provide an inline display of the referenced content. Visible indication and access may be user configurable.

Example Scripted longdesc Implementation