html - WGAC - 顺序降序
问题描述
在我的网页上,我有一篇很长的文章。
现在是一个 html 可能看起来像这样的示例(只是想象它更长):
<h1>Page title</h1>
<article>
<h2>Some title></h2>
<p>Content for that title</p>
<h2>Some other title </h2>
<p> some content for that other title </p>
</article>
这种模式仍在继续。
根据 WGAC,所有标题都应该按降序排列,这是一个问题,因为我的文章可能有超过 5 个 (h1 - h5) 标题。那么作为最佳实践我能做些什么呢?
每个标题都应该包含在<article>
or<section>
标记中还是可以h2
如上所示?
解决方案
例子
<main>
<h1>Different Front End Technologies</h1>
<p>Introduction...</p>
<section aria-labelledby="h2-html">
<h2 id="h2-html">HTML</h2>
<p>html...</p>
<h3>Sectioning Elements</h3>
<p>fjdfk</p>
<h4>The Header element</h4>
<h4>The Main element</h4>
<h3>Inline Elements</h3>
<p>fdsfa</p>
<h4>The time element</h4>
<h4>The address element</h4>
</section>
<section aria-labelledby="h2-css">
<h2 id="h2-css">CSS</h2>
<p>fdsafdas</p>
<h3>The Cascade</h3>
<h3>CSS Vars</h3>
<h4>The :root selector</h4>
<h4>Using a var in a property</h4>
<h5>Using calc() with a var</h5>
<h6>Example using calc()</h6>
<h6>Gotchyas using var in older browsers</h6>
<h5>var as inline style</h5>
</section>
<section aria-labelledby="h2-JS">
<h2 id="h2-JS">JavaScript</h2>
</section>
</main>
请注意 a 下的所有内容如何<h2>
与 that 相关<h2>
。a 下的所有内容<h3>
都与与<h3>
相关的内容有关<h2>
。这种情况继续下去。
当有彼此不再相关的主题时,您可以回到合适的标题级别。
“跳过标题级别”是当您从 a 跳到<h2>
a 时<h4>
- 这可能会让使用屏幕阅读器的人感到困惑,因为他们可能会使用屏幕阅读器中的快捷方式通过标题进行导航。
屏幕阅读器的奖金
如果您有一个非常复杂的文档并且您确定您没有过度嵌套项目,那么就屏幕阅读器而言实际上有 7 个标题级别。
推荐阅读
- python - 使用 glDraw 数组对立方体进行纹理处理时遇到问题
- sql - Oracle 存储过程中的 Select 语句
- reactjs - 包中的 ButtonProps 与包中的 Button 组件不兼容
- c# - 使用情节提要将用户控件中元素的宽度更改为另一个用户控件中元素的宽度
- matlab - 哪种类型的 MATLAB 绘图会根据特定条件在曲线上产生尖峰?
- android - Spinner 填充了 Firestore 中的多个文档如何删除所选项目?
- javascript - 添加 will-change: transform 到 css 会导致图片消失
- cname - 尽管 CNAME 已删除,但在 AWS CloudFront 上出现 CNAMEAlreadyExists 错误
- azure - 如何读取 XML 文件 Azure Databricks Spark
- ruby-on-rails - 升级到 5.2.1 后 Rails_admin 和 rails_admin_pundit 错误