Skip to content
学习 衡量 博客 Case studies 关于
Join and donate to 🇺🇦 DevFest for Ukraine, a charitable tech conference happening June 14–15 supported by Google Developers and Google Cloud.
本页内容
  • Lighthouse 标题级别审计如何失败
  • 资源

标题元素没有按降序顺序排列

Oct 17, 2019 — 更新日期 May 7, 2020
Available in: Español, 日本語, 한국어, Português, Русский, English
Appears in: 无障碍功能审核
本页内容
  • Lighthouse 标题级别审计如何失败
  • 资源

Screen readers have commands to quickly jump between headings or to specific landmark regions. In fact, a survey of screen reader users found that they most often navigate an unfamiliar page by exploring the headings.

By using correct heading and landmark elements, you can dramatically improve the navigation experience on your site for users of assistive technologies.

Lighthouse 标题级别审计如何失败 #

Lighthouse 会标记标题跳过一级或多级的页面:

显示标题跳级的 Lighthouse 审计

例如,对页面标题使用 <h1> 元素,接着对页面的主要部分使用 <h3> 元素,将导致审计失败,因为跳过了 <h2> 级别:

<h1>Page title</h1>
<h3>Section heading 1</h3>
…
<h3>Section heading 2</h3>
…
The Lighthouse Accessibility score is a weighted average of all the accessibility audits. See the Lighthouse accessibility scoring post for more information.

如何修复结构不良的标题 #

  • 使所有标题元素遵循反映内容结构的逻辑数字顺序。
  • 确保您的标题文本清楚地传达了相关部分的内容。

例如:

<h1>Page title</h1>
<section>
<h2>Section Heading</h2>
…
<h3>Sub-section Heading</h3>
</section>

检查标题结构的一种方法是提出以下问题:“如果有人只使用标题为我的页面创建大纲,这有意义吗?”

您还可以使用微软的 Accessibility Insights 扩展等工具来可视化您的页面结构并捕获无序的标题元素。

小心

开发人员有时会跳过标题级别以实现所需的视觉风格。例如,他们可能会使用 <h3> 元素,因为他们觉得 <h2> 文本太大。这被认为是一种反模式。相反,使用正确排序的标题结构并使用 CSS 来根据需要对标题进行视觉样式化。

有关更多信息,请参阅标题和陆标帖文。

资源 #

  • 标题跳级审计的源代码
  • 标题级别应逐一增加 (Deque University)
Last updated: May 7, 2020 — Improve article
Return to all articles
分享
订阅

Contribute

  • 提交错误
  • 查看源代码

相关内容

  • developer.chrome.com
  • Chrome 动态
  • 网站开发基础
  • 案例研究
  • 播客
  • 节目

连接

  • Twitter
  • YouTube
  • Google Developers
  • Chrome
  • Firebase
  • Google Cloud Platform
  • 所有产品
  • 条款和隐私权
  • 社区准则

Except as otherwise noted, the content of this page is licensed under the Creative Commons Attribution 4.0 License, and code samples are licensed under the Apache 2.0 License. For details, see the Google Developers Site Policies.