HTML <img> longdesc attribute

Definition and usage

longdesc attribute specifies a hyperlink to a detailed description of the image.

detail

<img> tag's longdesc attribute is associated with alt attribute similarly, but it allows for longer descriptive text.longdesc The value is a URL pointing to a document containing the image description. If the description is more than 1024 characters, then you can use longdesc attribute to set the link to it.

Neither HTML nor XHTML specifies what must be in the description, and currently browsers do not support longdesc attribute. Therefore, for creating those large blocks of descriptions, our suggestion is to create a hyperlink to a page containing the description.

alt The attribute is very helpful for the disabled, and for obvious reasons,longdesc The attribute seems to be a better option.

Example

Several examples of how to use the longdesc attribute:

<!-- The description is on the same page as the image -->
<img src="w3html.gif" alt="W3Schools.com" width="100" height="132" longdesc="#w3htmlExplained">
<!-- The description is on an external page -->
<img src="w3html.gif" alt="W3Schools.com" width="100" height="132" longdesc="w3html.txt">
<!-- This description is one of many in an external page -->
<img src="w3html.gif" alt="W3Schools.com" width="100" height="132" longdesc="http://example.com/desc#item3">
<!-- The description is included in the data:URI -->
<img src="w3html.gif" alt="W3Schools.com" width="100" height="132" longdesc="data:text/html;charset=utf-8;,%3C!DOCTYPE%20html%3E%3Chtml%3E%3Chead%3E%3Ctitle%3EDescription%20of%20the%20Logo%3C/title%3E%3C/head%3E%3Cbody%3E%3Cp%3ESome%20description%20goes%20here%3C/body%3E%3C/html%3E">

Try It Yourself

Syntax

<img longdesc="string">

Attribute Value

Value Description
string

Specifies a hyperlink that points to the detailed description of an image.

Possible Values:

  • Another Element's id
  • Absolute URL - Points to another website (such as longdesc="http://www.example.com/description.txt")
  • Relative URL - Points to a file within the website (such as longdesc="description.txt")

Browser Support

Chrome Edge Firefox Safari Opera
Chrome Edge Firefox Safari Opera
Not Supported Not Supported Not Supported Not Supported Not Supported