多个 h1 会导致屏幕阅读器问题吗?

编程入门 行业动态 更新时间:2024-10-26 18:25:47
本文介绍了多个 h1 会导致屏幕阅读器问题吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

当我放置一个通过 W3C 检查器构建的网站时,它要求我考虑仅使用 h1 作为顶级标题,并指出我在一个部分中有一个 h1 的部分.它还提到屏幕阅读器会将它们全部视为顶级元素,但是,根据 HTML5 规范,部分有效地重置"了标题,因此您可以在其中从 1-6 开始另一个层次结构.

When I put a website I am building through a W3C checker it asks me to consider only using h1's as a top level heading and points out a section where I have a h1 inside of a section. It also mentions that screen readers will treat them all as top level elements, however, according to HTML5 specs, sections effectively "reset" the headings so you can start another hierarchy from 1-6 within them.

如果我们试图专注于 W3C 验证和可访问性,我是否应该只在部分中使用 h2-h6?还是这个警告不正确?

Should I only be using h2-h6 within sections if we are trying to focus on W3C validation and accessibility? Or is this warning incorrect?

推荐答案

在任何地方使用 h1 是有效的(如果正确使用了分节元素),但 HTML5 规范鼓励作者使用排名对应的标题元素到节的嵌套 (h1-h6).

Using h1 everywhere is valid (if sectioning elements are used correctly), but the HTML5 spec encourages authors to use heading elements of the rank corresponding to the section’s nesting (h1-h6).

为什么鼓励不在任何地方使用h1,尽管这可以有益?很可能是因为并非所有相关的用户代理(如屏幕阅读器)都支持 HTML5 大纲算法.

Why encouraging not to use h1 everywhere, although this can be beneficial? Most likely because not all relevant user agents (like screen readers) support the HTML5 outline algorithm.

因此,如果您想支持不支持 HTML5 和/或大纲算法的屏幕阅读器,您可能需要按照建议使用适当等级的标题元素.

So if you want to support screen readers that don’t support HTML5 and/or the outline algorithm, you may want to follow the advice to use heading elements of the appropriate rank.

更多推荐

多个 h1 会导致屏幕阅读器问题吗?

本文发布于:2023-10-18 11:35:36,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1504113.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:多个   阅读器   屏幕

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!