可访问 PDF 的最佳标题文本 link

Best title text for accessible PDF link

我正在根据 WCAG 2.0 AA 标准对多个网站进行可访问性修复。这些站点有很多指向 PDF 的链接。这是他们拥有的一个常见示例:

<a href="/assets/pdf/pdf-file.pdf" target=_blank">Get Blah Information</a>

根据我对 WCAG 2.0 AA 原则的最佳理解,此链接应添加 title 文本,变成如下内容:

<a href="/assets/pdf/pdf-file.pdf" target=_blank" title="Opens PDF file in a new window">Get Blah Information</a>

我的问题是关于这个 title 文本的。这似乎只是偶尔合适。大多数浏览器将在新选项卡中打开 target="_blank",而不是新的 window。此外,在移动设备上,许多设备将启动本地应用程序来打开 PDF。一些 devices/browsers 会实际下载文件,具体取决于设置。考虑到所有这些因素,这些类型的文件是否有更好、更通用的标题?

在这种情况下我会避免使用 title 属性。它的使用有几个问题,在大多数情况下应该避免使用。例如,屏幕 reader 软件通常会读取 title 属性以及 link 中已有的文本,从而读取冗余且可能造成混淆的文本。 title 属性的处理方式在各种辅助技术中是不一致的。 Read more about when to use and not use the title attribute.

此外,我会避免描述将要发生的动作。如您所述,不同的 technology/devices 以不同的方式处理 link,用户甚至可以选择如何与 link 交互(在新选项卡中打开等)。相反,专注于描述 link 的目的。你的第一个例子:<a href="/assets/pdf/pdf-file.pdf" target=_blank">Get Blah Information</a> 比第二个好得多。

提醒人们他们点击的内容不会作为网页打开通常被认为是有礼貌的。

在我的组织中,我们要求 PDF links(或任何指向非 HTML 文档的 link)需要在锚文本中清楚地注释文件类型.

像这样: <a href="/assets/pdf/pdf-file.pdf">Get Blah Information (PDF)</a>

screen-reader/browser 组合不一致支持 title 属性,因此我不建议依赖它来工作。

Links to Non-HTML Resources https://webaim.org/techniques/hypertext/hypertext_links#non_html

Users should generally be alerted to links that lead to non-HTML resources, such as PDF files, Word files, PowerPoint files, and so on. However, there is some debate as to whether the content author or the browser should be the one to alert the user. The trouble is that none of the browsers or screen readers currently alert the user at all, so the debate is more theoretical than practical.

如果您反对将文件类型放在锚文本中,您始终可以使用 aria-label 属性来补充锚文本,或者 position the text off screen 以便视力正常的用户看不到它,尽管这些解决方案对于视力有限的用户来说可能不太容易获得。