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.
Syntax
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.
Values
Attribute Values
Historical values (do not use in new work):
Value
Description
Try it
URL
Address of a page or fragment with the long description
The diagram contrasts HTML structure with CSS presentation. Use this on-page text instead of longdesc.
Showing legacy longdesc markup (do not use).
Code
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">
Browsers do not expose a dependable “open longdesc” control. The attribute alone helps almost no one.
How It Works
Intent. Authors hoped AT would open a longer description file.
Reality. Support and discoverability were weak; the feature was misused.
Spec today. HTML marks longdesc obsolete for authors.
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>
The diagram shows HTML markup on one side and CSS rules on the other, illustrating how structure and presentation work together.
How It Works
Keep alt. Short alternative text stays on the image.
Put details on the page. Everyone can read them — not only a hidden URL.
Link visibly. An <a href="#…"> is the Standard’s recommended substitute.
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>
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.