HTML longdesc Attribute

Beginner
5 min read
Updated: Oct 2026
3 examples
Live preview

Definition and Usage

The longdesc attribute on <img> (and historically <iframe>) pointed to a longer description — usually a URL — when short alt text was not enough.

The HTML Standard lists it as obsolete: authors must not use it. Prefer a regular <a> link to the description, or on-page text with aria-describedby / aria-details.

Deprecated / obsolete.

Do not ship longdesc on new pages. Learn it to recognize legacy markup and migrate to discoverable alternatives.

HTML Syntax

syntax.html
<img src="…" alt="…" longdesc=" url-or-id">

Modern equivalent: keep alt, add a visible link (and optionally aria-describedby) to the long text.

Attribute Values

Historical values (do not use in new work):

ValueDescriptionTry it
URLAddress of a page or fragment with the long descriptionTry it
Element id (legacy)Some docs allowed an id reference; unreliable and obsoleteTry it
Modern: visible linkHTML Standard advice: use an <a> to the descriptionTry it
Modern: aria-describedbyAssociate the image with on-page description textTry it

Live Preview

Compare obsolete longdesc markup with a modern, discoverable description.

pattern

Prefer the modern pattern on real sites. Legacy markup is for recognition only.

Demo
<img src="chart.png" alt="Sales chart"
     longdesc="chart-description.html">

Obsolete: no reliable browser UI opens this URL for users.

Showing legacy longdesc markup (do not use).

HTML Examples

Short study snippets. Use Try It Yourself for a live editor. Ship only the modern patterns.

Example 1 — Recognize Legacy Markup

Old pages pointed longdesc at another document. Do not copy this into new work.

HTML
<!-- Obsolete — study only -->
<img
  src="/images/area-example.png"
  alt="HTML and CSS diagram"
  width="256"
  height="256"
  longdesc="diagram-description.html">
Try It Yourself

How It Works

  1. Intent. Authors hoped AT would open a longer description file.
  2. Reality. Support and discoverability were weak; the feature was misused.
  3. Spec today. HTML marks longdesc obsolete for authors.
  4. Action. When you see it, replace it with a visible description pattern.

Example 2 — Visible Link + On-Page Text

HTML’s advice: link to the description. Keep a solid alt, and associate text with aria-describedby.

HTML
<figure>
  <img
    src="/images/area-example.png"
    alt="HTML and CSS diagram"
    width="256"
    height="256"
    aria-describedby="diagram-desc">
  <figcaption>
    Structure vs presentation
    <a href="#diagram-desc">Long description</a>
  </figcaption>
</figure>

<p id="diagram-desc">
  The diagram shows HTML markup on one side and CSS rules on the other,
  illustrating how structure and presentation work together.
</p>
Try It Yourself

How It Works

  1. Keep alt. Short alternative text stays on the image.
  2. Put details on the page. Everyone can read them — not only a hidden URL.
  3. Link visibly. An <a href="#…"> is the Standard’s recommended substitute.
  4. Optional ARIA. aria-describedby ties the image to that description for assistive tech.

Example 3 — Expandable Long Description

Offer a button that reveals the long text when users want more detail.

HTML
<img
  id="diagram"
  src="/images/area-example.png"
  alt="HTML and CSS diagram"
  width="256"
  height="256"
  aria-describedby="diagram-desc">

<button type="button" id="toggle" aria-expanded="false" aria-controls="diagram-desc">
  Show long description
</button>

<div id="diagram-desc" hidden>
  Detailed walkthrough of each region in the diagram for users who need more than the short alt text.
</div>

<script>
  var btn = document.getElementById("toggle");
  var panel = document.getElementById("diagram-desc");
  btn.addEventListener("click", function () {
    var open = btn.getAttribute("aria-expanded") === "true";
    btn.setAttribute("aria-expanded", open ? "false" : "true");
    panel.hidden = open;
    btn.textContent = open ? "Show long description" : "Hide long description";
  });
</script>
Try It Yourself

How It Works

  1. Discoverable control. A button is clearer than an invisible longdesc URL.
  2. aria-expanded tells assistive tech whether the panel is open.
  3. hidden toggles visibility without removing the description from the document tree when open.
  4. Still use alt. The short alternative remains available either way.

Edge Cases & Pitfalls

Most problems came from invisible URLs and treating longdesc as a substitute for alt.

obsolete

Authors must not use it

Listed as obsolete for img and iframe in the HTML Standard. Delete it when you modernize pages.

alt

Never skip alt

longdesc never replaced the short text alternative. Every informative image still needs a meaningful alt.

discover

Invisible descriptions fail

If users (and many AT tools) cannot find the description, it does not help. Prefer visible links and on-page text.

iframe

Same story on frames

MDN marks iframe longdesc deprecated due to misuse. Describe framed content with nearby text or a link.

migrate

Replace, don’t stack

Do not keep longdesc “just in case.” Move the content into a linked page section or figcaption and remove the attribute.

Browser Support

longdesc is a legacy HTML attribute. Do not depend on browser UI for it.

✓ Obsolete · Do not use

longdesc

Historically present on img/iframe, but never a reliable user-facing feature. Modern engines and the HTML Standard treat it as obsolete for authors.

Legacy Not for new work
Google Chrome No useful longdesc UI
Obsolete*
Mozilla Firefox No useful longdesc UI
Obsolete*
Apple Safari No useful longdesc UI
Obsolete*
Microsoft Edge No useful longdesc UI
Obsolete*
Opera No useful longdesc UI
Obsolete*
Samsung Internet No useful longdesc UI
Obsolete*
Internet Explorer Legacy era only
Legacy*
longdesc Obsolete for authors

Bottom line: *Do not ship longdesc. Use visible description links and ARIA associations instead.

Key Takeaways

  • Status: obsolete on img / iframe — omit in new HTML.
  • Replace with: visible <a>, figure/figcaption, aria-describedby.
  • Keep alt: short text alternative is still required for informative images.
  • Goal: descriptions must be findable by people, not only stored in a hidden attribute.

One line: drop longdesc — link to (or reveal) a real description next to a good alt.

Frequently Asked Questions

On img (and historically iframe), longdesc pointed to a URL (or sometimes an id) for a longer description when alt was not enough. It is obsolete in the HTML Standard.
No. Authors must not use it. Prefer a visible link to the description, figure/figcaption, or aria-describedby / aria-details.
alt is the required short text alternative for the image. longdesc was meant for a separate, longer description resource. Keep writing good alt text; replace longdesc with modern patterns.
Support and discovery were poor, and the attribute was widely misused. Assistive tech and browsers never offered a reliable, consistent way for users to open it.
Link to the description with an a element, put details in figcaption or nearby text, and associate them with aria-describedby (or aria-details) when helpful.
Yes historically, but MDN and the HTML Standard mark iframe longdesc as deprecated/obsolete too. Describe frame content with visible text or a link instead.

Next: loop

Learn the loop attribute for repeating audio and video.

loop tutorial →

About the author

Mari Selvan M P
Mari Selvan M P 🔗

Developer, cloud engineer, and technical writer

  • Experience 12 years building web and cloud systems
  • Focus Full Stack Development, AWS, and Developer Education

I write practical tutorials so students and working developers can learn by doing—from databases and APIs to deployment on AWS.

8 people found this page helpful