大网数据广告活动
网站运营与故障问答

Where to put a long transcript of an image?

· 52CE 我爱测

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! …

问题原文

原帖链接 · 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 longdesc attribute 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 object element can have fallback content in case the image can’t be accessed:

    <object data="image.png" type="image/png">
      <!-- … -->
    </object>
    
  • The figure element can have a figcaption element:

    <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).

摘自公开归档,保留原文语言,版式经整理,外部媒体与邮箱地址已移除。

资料来源与适用范围

资料来源
Webmasters Stack Exchange
适用范围
以原帖系统、软件版本与发布日期为准(2016-03-27)
内容语言
中文;命令、路径和错误标识保留技术原文
本地收录日期
2026-11-15
授权说明
CC BY-SA 3.0

正文与所需资源由本站本地存储。查看来源及更新记录 ↗

请按适用版本和实际日志确认原因;本站没有对每一种系统或设备逐项执行文中的操作。