Html 多个 <nav> 标签
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/4676388/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
multiple <nav> tags
提问by stephenmurdoch
回答by coreyward
Yes, absolutely. You can have multiple header
, nav
, and footer
tags sans penalty.
是的,一点没错。您可以拥有多个header
、nav
和footer
标签而不受惩罚。
As long as you're making sure you are using tags semantically and you aren't putting them in invalid places (they're block-level elements, so you can't put them inside an inline element, for example) then you shouldn't worry too much about what the sticklers are saying. It's all to easy to get caught up arguing about tiny details instead of moving forward on your project.
只要您确保在语义上使用标签并且没有将它们放在无效的位置(例如,它们是块级元素,因此您不能将它们放在内联元素中),那么您应该不要太担心那些坚持者在说什么。很容易陷入争论细节而不是推进项目的过程。
回答by harold ramos
The answer is yes. You can have a <nav>
tag in the footer, for more info check mdn <nav>
documentation.
答案是肯定的。您可以<nav>
在页脚中有一个标签,有关更多信息,请查看mdn<nav>
文档。
回答by lucalanca
Yes, having multiple <nav>
elements is absolutely ok.
是的,拥有多个<nav>
元素绝对没问题。
You just have to make sure you're making them distinguishable for people using screen readers. You can do it by labelling each <nav>
using aria-label
.
您只需要确保让使用屏幕阅读器的人能够区分它们。您可以通过<nav>
使用标记每个来做到这一点aria-label
。
<nav aria-label='primary'>
<ul>
...List on links here...
</ul>
</nav>
<nav aria-label='secondary'>
<ul>
...List on links here...
</ul>
</nav>
Or, if one of the <nav>
as visible text on screen that can be identified as labelling element, you can use aria-labelledby
like follows:
或者,如果<nav>
屏幕上的可见文本之一可以识别为标签元素,则可以使用aria-labelledby
如下所示:
<nav aria-label="Site Menu">
<ul>
...List on links here...
</ul>
</nav>
<article>
<h1>Title</h1>
...
<nav aria-labelledby="id-1">
<h2 id="id-1">
Related Content
</h2>
<ul>
...List on links here...
</ul>
</nav>
</article>
You can read more about using Multiple Navigation Landmarks.
您可以阅读有关使用多个导航地标的更多信息。