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.
| 内容类别 | 流内容 , 区间内容 ,可触及内容。 |
|---|---|
| 准许内容 | 流内容 . |
| 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 接口 |
HTMLElement
|
此元素只包括 全局属性 .
<nav>
元素。
<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>
元素。
<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
范例
.
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>
| 规范 | 状态 | 注释 |
|---|---|---|
|
HTML 实时标准
The definition of '<nav>' in that specification. |
实时标准 | No change since latest W3C snapshot. |
|
HTML5
The definition of '<nav>' in that specification. |
推荐 | 初始定义 |
| 桌面 | 移动 | |||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|
nav
|
Chrome 完整支持 5 | Edge 完整支持 12 | Firefox 完整支持 4 | IE 完整支持 9 | Opera 完整支持 11.1 | Safari 完整支持 5 | WebView Android 完整支持 Yes | Chrome Android 完整支持 Yes | Firefox Android 完整支持 4 | Opera Android 完整支持 11.1 | Safari iOS 完整支持 4.2 | Samsung Internet Android 完整支持 Yes |
完整支持
<body>
,
<article>
,
<section>
,
<aside>
,
<h1>
,
<h2>
,
<h3>
,
<h4>
,
<h5>
,
<h6>
,
<hgroup>
,
<header>
,
<footer>
,
<address>
;