简体   繁体   English

HTML <header role=“menubar”> 无法在W3验证器上验证

[英]html <header role=“menubar”> not validating on w3 validator

I have this main header element that is a page-specific navigation menu. 我有一个主要的页眉元素,它是页面特定的导航菜单。 As you can see the h1 element is a link to (the menu is fixed to the top of the page while the rest scrolls down). 如您所见,h1元素是指向的链接(菜单固定在页面顶部,其余部分向下滚动)。

Example: 例:

<header role="menubar">
    <a href="#top">
        <h1>Main Title</h1>
    </a>
    <ul role="menu">
        <li role="menuitem">
            <a href="#presentation">presentation</a>
        </li>
        <li role="menuitem">
            <a href="#picture">picture</a>
        </li>
        <li role="menuitem">
            <a href="#downloads">downloads</a>
        </li>
    </ul>
</header>

on w3 validator I get as message: w3验证器上,我收到消息:

Error: Bad value menubar for attribute role on element header. 错误:元素标题上属性角色的错误值菜单栏。

.

referring me to the W3 recommendation page for single pages where the allowed ARIA roles for the header element are: 将我W3推荐页面(针对单个页面) ,其中标头元素允许的ARIA角色为:

banner role (default - do not set) or presentation. 标语角色(默认-不设置)或演示文稿。

.

'default - do not set' isn't really an option as it would not be backwards compatible because of the header element 'default-not set'并不是一个真正的选项,因为由于header元素,它不会向后兼容

'banner' and 'presentation' are not the correct roles (see banner and presentation ) “横幅”和“演示”角色不正确(请参见横幅演示

So my questions: 所以我的问题是:

  • What do I have to do? 我需要做什么? Easiest would be to replace the header element by a div element. 最简单的方法是将header元素替换为div元素。 But I think it is semantically less good, is that right? 但我认为从语义上讲不太好,对吗?

  • Is it possible that this case was not really considered by the W3C people or is it 100% wrong to do so (I mean on a semantic level focusing on accessibility). W3C人士可能没有真正考虑过这种情况,还是这样做100%错误(我的意思是专注于可访问性的语义级别)。

  • Are there other options? 还有其他选择吗?

thank you :) 谢谢 :)

What your current code shows is not a menubar but a navigation list. 当前代码显示的不是菜单栏,而是导航列表。 Instead of <header role="menubar"> you need <nav> and you should remove the role attributes from the list elements. 代替<header role="menubar">您需要<nav>并且应该从列表元素中删除角色属性。 If you are implementing a menu bar, your code is very incomplete. 如果要实现菜单栏,则代码非常不完整。

For advice on using HTML5 and WAI-ARIA for menu bars, see Recommended WAI-ARIA implementation for navigation bar/menu . 有关将HTML5和WAI-ARIA用于菜单栏的建议 ,请参阅导航栏/菜单的推荐WAI-ARIA实现

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM