Should the HTML file that a longdesc attribute (assigned to an img tag) points to, contain any markup?
Should the HTML file that a longdesc attribute (assigned to an img tag) points to, contain any markup, or should it just be text (not wrapped in any tags)?
HTML5 Image Description Extension (longdesc) (Working Draft) says:
It MUST be possible to include rich markup (e.g. HTML5) in the description of the image.
The linked description SHOULD be in a broadly accessible format.
It’s not clear to me if the requirement about structured markup is for implementors only or if it affects authors, too. If it concerns authors, using a plain text document wouldn’t be allowed, as these can’t contain "rich markup" (unless … well, it depends on the definition of rich markup). But I assume this requirement is for people implementing longdesc only (e.g., in CMS).
A "broadly accessible format" is not very well defined, either.
I guess in the end it should be fine to link to a document which your users can access. HTML would be a pretty safe bet, obviously. A plain text document should work, too, if it doesn’t contain a complex description which would need structured markup (see the the "Requires" lines in the example use cases).
There are a few options in the HMTL5 spec extension for longdesc, but the simplest thing is to have the description as a page.
I.e. From the image longdesc, target a separate page that is there purely to describe the image. As user-agent support is pretty poor, I would also include that as a link under the image that goes to the description page.
You can link to other things (e.g. plain text), but using a standard HTML page in your usual template is fine (assuming the template is reasonable accessible).
W3C does not specify explicitly whether it can or cannot contain the tags. But given that it needs to be a valid URL, the linked page should allow HTML formatting within it. To avoid this dilemma completely it is better to put the description of the image on the page itself and link it in the "longdesc" with #anchor-name of the section.
yes. not always, but most often, longdesc is going to be used by visually impaired users....who rely on screenreaders...which rely on content being appropriately marked up, to provide the best possible ux. in my opinion, you've already made the correct decision to use longdesc, yay! most people could careless. so why stop there? what's a few <h1> and <p> elements (usage will vary) going to hurt?