<nav>: The Navigation Section element - HTML: HyperText Markup Language 编辑
The HTML <nav>
element represents a section of a page whose purpose is to provide navigation links, either within the current document or to other documents. Common examples of navigation sections are menus, tables of contents, and indexes.
The source for this interactive example is stored in a GitHub repository. If you'd like to contribute to the interactive examples project, please clone https://github.com/mdn/interactive-examples and send us a pull request.
The source for this interactive example is stored in a GitHub repository. If you'd like to contribute to the interactive examples project, please clone https://github.com/mdn/interactive-examples and send us a pull request.
Content categories | Flow content, sectioning content, palpable content. |
---|---|
Permitted content | Flow content. |
Tag omission | None, both the starting and ending tag are mandatory. |
Permitted parents | Any element that accepts flow content. |
Implicit ARIA role | navigation |
Permitted ARIA roles | No role permitted |
DOM interface | HTMLElement |
Attributes
This element only includes the global attributes.
Usage notes
- It's not necessary for all links to be contained in a
<nav>
element.<nav>
is intended only for major block of navigation links; typically the<footer>
element often has a list of links that don't need to be in a<nav>
element. - A document may have several
<nav>
elements, for example, one for site navigation and one for intra-page navigation.aria-labelledby
can be used in such case to promote accessibility, see example. - User agents, such as screen readers targeting disabled users, can use this element to determine whether to omit the initial rendering of navigation-only content.
Examples
In this example, a <nav>
block is used to contain an unordered list (<ul>
) of links. With appropriate CSS, this can be presented as a sidebar, navigation bar, or drop-down menu.
<nav class="menu">
<ul>
<li><a href="#">Home</a></li>
<li><a href="#">About</a></li>
<li><a href="#">Contact</a></li>
</ul>
</nav>
Specifications
Specification | Status | Comment |
---|---|---|
HTML Living Standard The definition of '<nav>' in that specification. | Living Standard | No change since latest W3C snapshot. |
HTML5 The definition of '<nav>' in that specification. | Recommendation | Initial definition |
Browser compatibility
BCD tables only load in the browser
See also
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论