HTML longdesc Attribute

Beginner
⏱️ 6 min read
📚 Updated: Jun 2026
🎯 3 Examples
Deprecated & Accessibility

Introduction

The longdesc attribute was designed to point from an <img> element to a URL containing a longer description of the image—useful for complex charts or diagrams where alt alone is too short. It is now obsolete in HTML5. Browsers never implemented it consistently, and modern accessibility guidelines recommend on-page descriptions with aria-describedby, <figure>/<figcaption>, or visible “Long description” links instead.

What You’ll Learn

01

URL Value

Legacy pattern.

02

Obsolete

Not in HTML5.

03

longdesc vs alt

Short vs long.

04

aria-describedby

Modern fix.

05

figure

Caption + image.

06

Migration

Replace legacy.

Purpose of longdesc

The original purpose of longdesc was to improve accessibility for complex images by linking to a separate document with a full textual description—for example, a detailed explanation of a scientific chart or map that would not fit in the alt attribute.

Because the URL was hidden with no standard UI in most browsers, users often never discovered the long description. HTML5 removed longdesc from the specification. You should understand it when maintaining legacy pages, but not add it to new work.

⚠️
Do not use in new projects

The old reference suggested using longdesc whenever possible. That advice is outdated. Use the modern patterns in this tutorial instead—they work in today’s browsers and assistive technology.

📝 Syntax

Legacy syntax (recognition only):

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

Modern replacement:

longdesc-modern.html
<figure>
  <img src="chart.png" alt="Sales chart 2024"
       aria-describedby="chart-desc">
  <figcaption>Sales by quarter</figcaption>
</figure>
<p id="chart-desc">Detailed description of the chart…</p>

Syntax Rules

  • Historically on <img> (and rarely <frame> in old HTML).
  • Value was a URL string pointing to an HTML page with the extended description.
  • Always required a meaningful alt as well—longdesc was supplemental, not a replacement.
  • Obsolete in HTML5—validators flag it; do not use on new images.
  • Use same-document ids with aria-describedby for screen reader associations.
  • Legacy DOM property: longDesc (camelCase) on HTMLImageElement.

💎 Values

The longdesc attribute accepted a URL referencing a document with the long description:

  • longdesc="chart-description.html" — Relative URL on the same site.
  • longdesc="https://example.com/descriptions/photo.html" — Absolute URL.
  • longdesc="#details" — Fragment URL to an on-page section (rarely supported reliably).

Modern equivalent uses an element id, not a separate attribute on img:

longdesc-js.html
// Legacy (avoid):
img.longDesc = "old-page.html";

// Modern:
img.setAttribute("aria-describedby", "photo-desc");

⚡ Quick Reference

NeedLegacy (avoid)Modern approach
Short labelalt="..."alt="..." (still required)
Long descriptionlongdesc="page.html"aria-describedby="id"
Visible captionN/A<figure> + <figcaption>
Link to detailsHidden URL onlyVisible “Long description” link
Complex chartSeparate HTML fileOn-page <div id> or data table

Applicable Elements

Element / ContextSupported?Notes
<img>ObsoletePrimary historical use
<frame> (HTML4 frames)ObsoleteLegacy framesets only
<input>, <area>NoUse alt on area; labels on inputs
aria-describedbyModern replacementOn any element including img

longdesc vs alt vs aria-describedby

Featurealtlongdescaria-describedby
StatusRequired standardObsoleteStandard WAI-ARIA
LengthShort (typically < 125 chars)Long (separate page)Long (on-page element)
Where text livesAttribute valueExternal URLElement referenced by id
Browser UIShown if image failsNone (broken UX)AT reads description
Use today?YesNoYes

Examples Gallery

Legacy longdesc markup, a modern accessible figure pattern, and toggling a visible long description.

👀 Live Preview

Modern pattern with visible long-description link:

Bar chart showing rising quarterly sales
Quarterly sales chart Long description

Q1 sales were 12 units, Q2 18, Q3 24, and Q4 30—a steady upward trend across the year.

Example — Legacy longdesc (Do Not Use)

index.html
<img src="example.jpg" alt="Example Image" longdesc="longdesc.html">
Try It Yourself

How It Works

The attribute pointed to a separate document. Because discovery failed for most users, the feature was removed from HTML5.

Example — Modern Accessible Pattern

accessible-image.html
<figure>
  <img src="chart.png" alt="Quarterly sales bar chart"
       aria-describedby="chart-long-desc">
  <figcaption>
    Sales 2024
    <a href="#chart-long-desc">Long description</a>
  </figcaption>
</figure>
<div id="chart-long-desc">
  Q1 through Q4 show steady growth from 12 to 30 units…
</div>
Try It Yourself

How It Works

The description stays on the same page where everyone can find it. aria-describedby links the image to the detailed text programmatically.

Example — Expandable Long Description

toggle-desc.html
<img id="diagram" src="diagram.png" alt="Network diagram"
     aria-describedby="diagram-desc">
<button type="button" aria-expanded="false" aria-controls="diagram-desc">
  Show long description
</button>
<div id="diagram-desc" hidden></div>
Try It Yourself

How It Works

An expandable panel replaces the hidden external URL pattern of longdesc with discoverable, keyboard-accessible UI.

♿ Accessibility

  • Always provide alt — Even with a long description, images need concise alternative text.
  • Do not use longdesc on new sites — It is obsolete and poorly supported.
  • Put long text on the same page — Link with aria-describedby or a visible anchor.
  • Make descriptions discoverable — Unlike longdesc, visible links help sighted users too.
  • Use aria-expanded on toggles — Announce show/hide state for description panels.
  • Consider a data table — For charts, an accessible table of the same data benefits everyone.

🧠 How longdesc Worked (Legacy)

1

Author sets longdesc URL

Points off-page.

Markup
2

Browser shows image only

No standard link UI.

Problem
3

AT support inconsistent

Users miss details.

A11y gap
=

Use aria-describedby today

On-page, visible, reliable.

Browser Support

The longdesc attribute is obsolete. No browser provides a standard, discoverable UI for it. Firefox once offered optional longdesc discovery; most engines ignore the attribute for practical purposes.

⚠️ Obsolete · Not recommended

Removed from HTML5

Do not depend on longdesc in any modern browser.

0% Recommended use
longdesc on img Do not use

Bottom line: Recognize it in legacy HTML; migrate to aria-describedby and visible description links.

💡 Best Practices

✅ Do

  • Write concise, accurate alt text on every meaningful image
  • Add on-page long descriptions for complex visuals
  • Use aria-describedby to associate img with description id
  • Provide visible “Long description” links or expandable panels
  • Replace longdesc when refactoring legacy pages

❌ Don’t

  • Add longdesc to new markup
  • Put paragraphs of text inside alt
  • Hide the only description on a separate page with no link
  • Assume SEO tools reward longdesc (they don’t)
  • Skip testing with screen readers after migration

Conclusion

The longdesc attribute was an early attempt at long image descriptions via external URLs, but poor browser support and hidden discovery led to its removal from HTML5.

For accessible, inclusive pages today, combine alt with on-page detailed text linked through aria-describedby, <figure>, and visible description controls. That approach serves both assistive technology and sighted users.

Key Takeaways

Knowledge Unlocked

Five truths every developer should know about longdesc

Bookmark these before describing complex images.

5
Core concepts
🔗 02

URL value

External page

Legacy
📝 03

alt stays

Short summary

Required
04

aria-describedby

Modern link

Replace
👁 05

Visible link

Discoverable UI

UX

❓ Frequently Asked Questions

It historically held a URL to a page with a detailed image description. It is obsolete and should not be used in new HTML.
Not in any practical, standards-based way. Browsers do not expose a reliable UI for it. Use modern accessibility techniques instead.
aria-describedby referencing an on-page element, plus a visible long-description link or expandable section.
alt is a short summary in the attribute itself. longdesc pointed to a long external description. Keep alt brief; put long text in page content.
Search engines do not treat longdesc as a meaningful signal. Descriptive alt text and visible page content around images matter more.
Legacy code may use img.longDesc. New code should set aria-describedby instead.

Describe complex images the modern way

Learn why longdesc was retired and practice aria-describedby with visible description links in the Try It editor.

Try modern accessible pattern →

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.

5 people found this page helpful