longdesc
)Copyright © 2015 W3C® (MIT, ERCIM, Keio, Beihang). W3C liability, trademark, document use and software licensing rules apply.
This specification defines a longdesc
attribute (based on
the longdesc
attribute of HTML 4) to link descriptions to
images in HTML5 content.
By allowing a hyperlink inside another one, this document explicitly redefines the HTML concept of hyperlink in a limited set of circumstances.
This is an editor's draft and has no official standing.
Text alternatives are used to make visual information accessible by describing
the information or function represented in an image. The alt
attribute is designed to provide a concise description or functional equivalent
for an image. For some images and contexts, more detail is required to convey
all the information contained in the image. The longdesc
attribute
is designed as a means to provide this level of detail.
HTML 4 provided a longdesc
attribute for the img
element that enabled a machine-discoverable description of an image to
be linked to the image. This extension specification defines a longdesc
attribute to provide that functionality for HTML5.
Example: (Informative)
<!-- The description is somewhere on the same page as the image -->
<img src="http://example.com/graph1" alt="Drinks are getting sweeter"
longdesc="#graph1Explained">
<!-- The description is a page on its own -->
<img src="figure1" alt="figure 1" longdesc="http://example.com/desc1">
<!-- The description is one of several within an external page -->
<img src="ExampleImage" alt="example" longdesc="http://example.com/descs#item3">
<!-- The description is included in a data: URI -->
<img src="logo" alt="W3C" longdesc="data:text/html;charset=utf-8;,%3C!DOCTYPE%20html%3E
%3Chtml%3E%3Chead%3E%3Ctitle%3EDescription%20of%20the%20W3C%20Logo%3C/title%3E%3C/head%3E
%3Cbody%3E%3Cp%3EA%20blue%20capital%20letter%20%22W%22%20with%20kerning%20so%20it%20
touches%20a%20blue%203%2C%20followed%20by%20a%20black%20shadow%20of%20a%20white%20
capital%20letter%20C%20all%20on%20a%20white%20background%3C/body%3E%3C/html%3E">
All authoring guidelines, diagrams, examples, notes, and sections marked "informative" in this specification are informational. Everything else in this specification is "normative" as described in [QAFRAME].
The key words "must", "should", "should not" and "may" in this specification are to be interpreted as described in [RFC2119].
The Interface Definition Language (IDL) fragments in this specification must be interpreted as required for conforming IDL fragments, as described in the Web IDL specification. [WEBIDL]
The terms "valid non-empty URL potentially surrounded by spaces", "hyperlink", and "reflect", used in this specification are defined in [HTML5], although this specification modifies the semantics of the term "hyperlink" in allowing hyperlinks to be nested in certain specific circumstances.
This document uses the terms accessible and accessibility in the sense of ensuring people with disabilities can use the Web. Further information is available, e.g. Introduction to Web Accessibility.
The longdesc
attribute gives authors a mechanism for referencing a long text
description for images which cannot be adequately described using shorter description
mechanisms, such as in the following use cases.
longdesc
AttributeThis extension changes the definition of a hyperlink in HTML,
by allowing a longdesc
attribute to occur inside a
hyperlink.
Zero or one longdesc
attributes may
be added to any img
element.
The longdesc
attribute must
contain a valid
non-empty URL potentially surrounded by spaces. The URL is a hyperlink
to a description of the image that the parent img
element represents.
The linked description should be in a broadly accessible format.
This section is informative
Best practices for checking descriptions of images are beyond the scope of this document, but there are many resources available. For further guidance authoring tool developers can consult e.g. Appendix A-3: Long text descriptions of [ATAG].
High quality implementation in authoring and content management tools is likely to include checking for common errors, such as including a description instead of a URL in the attribute, or pointing to a resource that is an image or plain text, which are often poor choices for a high-quality description. Additional examples of error checking and repair options can be found in Appendix B: Levels of Checking Automation and Appendix C: Levels of Repair Automation of [ATAG]
When a description is only part of the target document, authors should link to a container element in the target document that contains the entire description.
This section is informative
Note that while in some cases this will allow user agents to present the description, there will be cases where user agents cannot or do not automatically restrict the information presented to the container element.
Example: (Informative)
<!-- Image with description that is only part of target document -->
<img src="foo.png" alt="Example image" longdesc="example.html#desc2">
<!-- Target document -->
<section id="desc2">
<h2>Image foo.png</h2>
<p>Description of the image...</p>
</section>
This section is informative
Best practices for full descriptions of images are beyond the scope of this document, but there are many resources available.
Authors should not rely solely on longdesc where standards exist to provide direct, structured access.
This section is informative
For example a MathML version of mathematical content, or an SVG image that uses the accessibility features of SVG, can provide direct accessibility to users with appropriate technology. In such cases, it is appropriate to use those techniques in combination with longdesc.
If the longdesc
value is valid, User agents must
make the link available to all users through the regular user
interface(s).
If the longdesc
value is valid, User agents must
expose the longdesc to relevant APIs, especially accessibility-oriented
APIs, in a manner most appropriate to the API.
This section is informative
What is most appropriate to an API will vary with the individual API. Some APIs (like MSAA) will need the text string which constitutes the URL of the longdesc value. Other APIs may provide an actionable interface.
User agents should enable users to discover when images in a page contain a long description.
This section is informative
longdesc
can be present on an image within a
hyperlink. This does not change the requirements on user agents,
which must still enable the hyperlink to be followed.
Complete documentation of best practices for implementation is beyond the scope of this document. These notes are offered to help minimize the impact of common mistakes.
A common mistake in the past has been to use a description, instead of a URL that links to a description. Converting such values to data: URLs is a repair strategy for user agents that can help users to recover in cases where authors have made this mistake.
It is usually helpful when the behavior for finding, reading, and returning from a long description to the image described is a consistent experience.
Further information on making user agents accessible can be found in [UAAG].
HTMLImageElement
Interface
partial interface HTMLImageElement {
attribute DOMString longDesc;
};
longDesc
of type DOMStringThe longDesc
IDL attribute must be a valid
non-empty URL potentially surrounded by spaces. It defines a
hyperlink to a detailed description of the image its parent HTMLImageElement
represents.
The longDesc
IDL attribute must
reflect
the HTML content attribute longdesc
.
This section is informative
image.longDesc
[ = value ]
Returns a DOMString that represents the attribute's contents.
Can be set, to replace the contents of the attribute with the given string.
Example: (Informative)
/*Make the first internal longdesc reference absolute*/
var baseURL = document.location.origin + document.location.pathname
var someImage = document.querySelector('img[longdesc^=#]');
someImage.longDesc = baseURL + someImage.longDesc;
Example: (Informative)
/*Open new windows for each longdesc found*/
var describedImages = document.querySelectorAll('img[longdesc]');
for (i in describedImages) {
if (i.longdesc)
window.open(i.longDesc);
}
Example: (Informative)
/*Tries to repair errors where the longdesc isn't a URI*/
var describedImages = document.querySelectorAll('img[longdesc]');
for (i in describedImages) {
if (i.longDesc && !(validURL(i.longDesc)) { //assumes some URL validating function
var theData = encodeURIComponent(i.longDesc);
i.longDesc = "data:text/plain;charset=";
i.longDesc += document.charset;
i.longDesc += theData;
}
}
This section is informative
Thanks to the HTML Working Group of the late 1990s for the original specification of longdesc, to those who have implemented it in various kinds of software, and to many many people involved with the development of HTML5 (including but not limited to those who discussed "ISSUE-30" in the HTML Working Group, the Protocols and Formats Working Group, the W3C Advisory Board, and around countless dinner tables, coffee breaks, and elsewhere) for the ideas, discussions and contributions that led to the initial draft of this specification. With the exception of Laura Carlson, who did far more very valuable work than it took to produce this specification, they are not individually named: the list might be larger than the content of the specification.
For specific comments and suggestions that led to improvements over successive drafts of this specification, thanks to the W3C's HTML Accessibility Task Force, the W3C Internationalization Working Group, and to Jonathan Avila, Robin Berjon, James Craig, Paul Cotton, Steve Faulkner, John Foliot, Geoff Freed, Peter Gruzca, Richard Ishida, Anne van Kesteren, David MacDonald, Michelle McManus, Chris Mills, Jay Munro, Devarshi Pant, Marta Pawlowska, Silvia Pfeiffer, Wendy Seltzer, Leif Halvard Silli, Mathew Turvey, Klaas 'Z4us' V, and Boris Zbarsky. The code examples are rendered with Lea Verou's prism tools. Any errors are despite, not as a result of, their efforts.
This publication has been funded in part with Federal funds from the U.S. Department of Education, National Institute on Disability and Rehabilitation Research (NIDRR) under contract ED-OSE-10-C-0067. The content of this publication does not necessarily reflect the views or policies of the U.S. Department of Education, nor does mention of trade names, commercial products, or organizations imply endorsement by the U.S. Government.
This section is informative
Editorial changes include:
Editorial changes include:
longdesc
attribute.Editorial changes include:
longdesc
makes a limited
change to the semantics of the term "hyperlink" in HTMLSubstantive changes include:
longdesc
should be "accessible".longdesc
.longdesc
.longdesc
was changed to reflect
the HTML content attribute longdesc
.Editorial changes include: