HTML longdesc Attribute

The obsolete HTML longdesc attribute was historically used with images and inline frames to provide the URL of a separate resource containing a more detailed description of the content.

Historical Syntax

The longdesc attribute contained a URL pointing to a separate resource with a detailed description:

<img src="chart.png"
     alt="Annual sales chart"
     longdesc="chart-description.html">

The alt attribute provided the image's alternative text, while longdesc pointed to a separate page containing a more extensive description.

Historical Elements

The obsolete longdesc attribute was associated with the <img> and <iframe> elements.

Element Historical Purpose
<img> Provided a URL containing a detailed description of an image.
<iframe> Provided a URL containing a detailed description of the inline frame's content.

Historical Use

The longdesc attribute was intended for content that needed a more extensive description than could reasonably be provided by short alternative text. Examples could include complex charts, diagrams, maps, or other detailed visual information.

The attribute contained a URL rather than the description itself. A supporting browser or assistive technology could make that separate description available to the user.

The longdesc attribute did not replace the alt attribute on an image. The alt attribute still provided the image's text alternative, while longdesc supplied access to additional descriptive information when needed.

Why It Became Obsolete

The longdesc attribute depended on browsers and assistive technologies providing a usable way for people to discover and follow its URL. A normal hyperlink is more directly available to users and does not require special handling of the attribute.

Modern HTML can place a detailed description directly near the image or provide an ordinary link to a separate description. These approaches use standard page content and navigation that users can readily discover and access.

Modern Alternative

Use appropriate alt text for an image and, when a longer description is needed, provide the description in the surrounding content or use a regular hyperlink to a more detailed explanation.

Historical HTML

<img src="chart.png"
     alt="Annual sales chart"
     longdesc="chart-description.html">

Modern HTML

<figure>
  <img src="chart.png" alt="Annual sales increased from 2023 through 2026.">
  <figcaption>
    Annual sales from 2023 through 2026.
    <a href="chart-description.html">Read the detailed chart description</a>.
  </figcaption>
</figure>

In this example, the image has useful alternative text and the detailed description is available through a normal hyperlink that can be discovered and followed like any other link.

If the complete description is reasonably short, it can instead be included directly in the page near the image. This can make the information available without requiring the user to open another page.

The alt Attribute Still Matters

Replacing longdesc with a visible link does not eliminate the need for appropriate alternative text. The alt attribute provides replacement text for an image when the image cannot be seen or processed. The detailed description provides additional information when the image is too complex to explain adequately with a short text alternative.

Legacy Browser Support

Support for exposing and accessing longdesc varied among browsers and assistive technologies, so users could not always depend on the description link being readily available.

Modern webpages should use standard HTML content and regular hyperlinks when detailed descriptions are needed rather than depending on legacy longdesc behavior.

For additional information about historical browser compatibility, visit Can I Use? . Search for the HTML element or attribute you want to check. Search results can include related HTML features, element attributes, APIs, and other technologies, so select the result that most closely matches the legacy feature you are researching.

Other attributes related to images and alternative content include:

  • alt - Provides alternative text for an image and remains an important current HTML attribute.
  • src - Specifies the image or embedded resource to load.
  • lowsrc - An obsolete image attribute historically used to specify a lower-resolution image while another image loaded.

Specifications

The longdesc attribute on the <img> and <iframe> elements is obsolete. The HTML Living Standard recommends using a regular <a> element to link to a description. For images, an image map can also provide a link to the image's description. See the WHATWG HTML Living Standard for information about obsolete and non-conforming features.