标志和标题Landmarks and Headings

用户界面通常以直观高效的方式进行组织,从而允许视力正常的用户快速浏览自己感兴趣的内容,无需放慢速度来阅读全部内容。A user interface is typically organized in a visually efficient way, allowing a sighted user to quickly skim for what interests them without having to slow down to read all the content. 屏幕阅读器用户需要这种相同的浏览能力。A screen reader user needs to have this same skimming ability. 标志和标题定义帮助辅助技术 (AT) 用户更高效导航的用户界面的各个部分。Landmarks and headings define sections of a user interface that aid in more efficient navigation for users of assistive technology (AT). 将内容标记为标志和标题可为屏幕阅读器用户提供与视力正常的用户所采用方式类似的浏览内容的选项。Marking up the content into landmarks and headings provides a screen reader user the option to skim content similar to the way a sighted user would.

ARIA 标志ARIA 标题HTML 标题的概念数年来一直用在 Web 内容中,以允许屏幕阅读器用户更快地浏览。The concepts of ARIA landmarks, ARIA headings, and HTML headings have been used in web content for years to allow faster navigation by screen reader users. 网页利用标志和标题通过允许 AT 用户快速到达大区块(标志)和较小区块(标题)来使其内容更易于使用。Web pages utilize landmarks and headings to make their content more usable by allowing the AT user to quickly get to the large chunk (landmark) and smaller chunk (heading). 具体来说,屏幕阅读器具有允许用户在标志之间跳转和在标题之间跳转(下一个/上一个或特定标题级别)的命令。Specifically, screen readers have commands allowing users to jump between landmarks and jump between headings (next/previous or specific heading level). 由于同样原因,请务必考虑你的应用中的标志和标题。It is important to consider landmarks and headings in your apps for the same reasons.

标志启用要分组到各个类别(如搜索、导航、主内容等)中的内容。Landmarks enable content to be grouped into various categories such as search, navigation, main content, and so on. 分组后,AT 用户可以在各个组之间快速导航。Once grouped, the AT user can quickly navigate between the groups. 这种快速导航允许用户跳过潜在的大量内容,这些内容在以前可能必须按项目进行导航,从而产生糟糕的体验。This quick navigation allows the user to skip potentially substantial amounts of content which previously may have had to be navigated over item by item making for a poor experience.

例如,当使用标签面板时,将此视为导航标志。For example, when using a tab panel, consider this a navigational landmark. 当使用搜索编辑框时,将此视为搜索标志并考虑将你的主内容设置为主内容标志。When using a search edit box, consider this a search landmark and consider setting your main content as a main content landmark. 无论是在标志内还是在标志外,请考虑将子元素设置为具有逻辑标题级别的标题。Whether within a landmark or even outside a landmark, consider setting sub elements as headings with logical heading levels.

请考虑使用 Windows 设置应用中的轻松访问页面。Consider the Ease of Access page in the Windows Settings app.

Windows 设置应用中的“轻松访问”页面

搜索标志内有一个环绕的搜索编辑框。There is a search edit box which is wrapped within a search landmark. 左侧的导航元素环绕在导航标志内,右侧的主内容环绕在主内容标志内。The navigational elements on the left are wrapped within a navigational landmark and the main content on the right is wrapped within a main content landmark. 更进一步说明,在导航标志内,有一个名为轻松访问的主组,其为标题级别 1。Taking this further, within the navigational landmark there is a main group heading called Ease of Access which is a heading level 1. 在此之下是子选项视觉听觉,依此类推。Under that are the sub options Vison, Hearing, and so on. 这些具有标题级别 2。These have a heading level 2. 设置标题针对设置主要主题继续在主内容内进行,显示 作为标题级别 1 而且子组(如使一切变大作为标题级别 2。Setting headings is continued within the main content again setting the main subject, Display, as heading level 1 and sub groups such as Make everything bigger as heading level 2.

设置应用将可供访问,无需标志和标题,但会变得更易于使用它们。The Settings app would be accessible without landmarks and headings, but it becomes more usable with them. 屏幕阅读器用户可以快速轻松地到达其所需的组(标志),然后也快速到达子组(标题)。A screen reader user can quickly and easily get to the group (landmark) they need and then quickly get to the sub group (heading) as well.

使用 AutomationProperties.LandmarkTypeProperty 将 UI 元素设置为所需的标志类型Use AutomationProperties.LandmarkTypeProperty to setup the UI element as the type of landmark you wish. 此标志 UI 元素将封装对于该标志来说有意义的所有其他 UI 元素。This landmark UI element would encapsulate all the other UI elements which make sense for that landmark.

使用 AutomationProperties.LocalizedLandmarkTypeProperty 专门命名该标志。Use AutomationProperties.LocalizedLandmarkTypeProperty to specifically name the landmark. 如果你选择预定义的标志类型,如主或导航,这些名称将用于标志名称。If you select a predefined landmark type such as main or navigational, these names will be used for the landmark name. 但是,如果将标志类型设置为自定义,你必须通过此属性专门命名标志。However, if you set the landmark type to custom you must specifically name the landmark through this property. 你还可以使用此属性覆盖非自定义标志类型中的默认名称。You can also use this property to override the default names from the non-custom landmark types.

使用 AutomationProperties.HeadingLevel 将 UI 元素设置为从 Level1Level9 内某特定级别的标题。Use AutomationProperties.HeadingLevel to set the UI element as a heading of a specific level from Level1 through Level9.

示例Examples

有关演示如何解决 Windows 桌面应用程序中的许多常见编程式辅助功能问题的许多代码示例,请参阅 解决 windows 桌面应用程序中的常见编程式辅助功能问题的代码示例For numerous code samples showing how to resolve many common programmatic accessibility issues in Windows desktop apps, see Code samples for resolving common programmatic accessibility issues in Windows desktop apps.

这些代码示例是由 Microsoft 的 可访问性 Insights (适用于 Windows)直接引用的,它们有助于在 UI 中突出出现许多辅助功能问题。These code samples are referenced directly by Microsoft Accessibility Insights for Windows, which can help to spotlight many accessibility issues in UI.