问题原文
原帖链接 · Robert · CC BY-SA 3.0
I am making a comic web site. Each comic is a single png and has a html page. For each comic I have a transcript, like this:
A and B are sitting on a bench in the park.
A: Nice weather today.
B gives him a weird look: Too rainy!
A: ...
Where I should put that transcript in the html?
<meta name="description" content="transcript"/> seemed like a good place, but it seems limited to 155 characters, and my transcripts may be longer than that (up to 900 characters).
The <img>'s alt attribute might work, but that could be limited in length as well.
I could add it to the page in an invisible div with style="display: none" (like old XKCD comics do) but I don't want to have search engines think I am trying to cheat with invisible text.
已采纳解答
原帖链接 · unor · CC BY-SA 3.0
Using the alt attribute in such cases is not ideal, because often some markup/structure is needed to describe the image’s content, which alt does not allow (it can only contain plain text).
Other options:
The
longdescattribute allows you to link to a page (or an element on the same page) that contains the "long text description" of an image:<img src="image.png" alt="…" longdesc="#transcript" />The
objectelement can have fallback content in case the image can’t be accessed:<object data="image.png" type="image/png"> <!-- … --> </object>The
figureelement can have afigcaptionelement:<figure> <img src="image.png" alt="…" /> <figcaption>…</figcaption> </figure>
For accessibility, it would be best to provide the transcript for everyone, not only for screen reader users. Many users that could benefit from a transcript don’t use a screen reader, so visually hidden content is really hidden to them.
For the same reason, relying on alt or using an object element isn’t ideal either, and if longdesc gets used, you should also add a hyperlink for users that don’t use a user agent with longdesc support.
So ideally you would simply show the transcript on the same page (or another page, and link to it). If using figure+figcaption, the relationship is clear; otherwise use longdesc to connect the img with the transcript (and provide a hyperlink if it’s on a different page or not next to the img).
摘自公开归档,保留原文语言,版式经整理,外部媒体与邮箱地址已移除。
