--- title: <nav> slug: Web/HTML/Element/nav tags: - 元素 - 區域 - 導航欄 - 網站 - 網站區域 - 網頁 - 網頁區域 - 連結 translation_of: Web/HTML/Element/nav --- <div>{{HTMLRef}}</div> <p><span class="seoSummary"><strong>HTML <nav> 元素</strong>代表一個網頁中提供導航欄連結的區域,不管是當前網頁或者其他網頁,還是這個連結最終抵達的只是當前網頁的某個區塊,或者會抵達其他網頁,常見的導航欄範例有菜單、內容的表單,以及頁面本身。</span></p> <table class="properties"> <tbody> <tr> <th scope="row"><a href="/zh-TW/docs/HTML/Content_categories">Content categories</a></th> <td><a href="/zh-TW/docs/HTML/Content_categories#Flow_content">流內容</a>、<a href="/zh-TW/docs/HTML/Content_categories#Sectioning_content">sectioning content</a>、palpable content.</td> </tr> <tr> <th scope="row">允許內容</th> <td><a href="/zh-TW/docs/HTML/Content_categories#Flow_content">流內容</a>。</td> </tr> <tr> <th scope="row">省略標籤</th> <td>{{no_tag_omission}}</td> </tr> <tr> <th scope="row">Permitted parents</th> <td>Any element that accepts <a href="/en-US/docs/HTML/Content_categories#Flow_content">flow content</a>.</td> </tr> <tr> <th scope="row">Permitted ARIA roles</th> <td>None</td> </tr> <tr> <th scope="row">DOM interface</th> <td>{{domxref("HTMLElement")}}</td> </tr> </tbody> </table> <h2 id="屬性">屬性</h2> <p>此元素只有<a href="/zh-TW/docs/HTML/Global_attributes">全域屬性</a>。</p> <h2 id="使用筆記">使用筆記</h2> <ul> <li>不是所有的文件連結都需要在 <code><nav></code> 元素裡面,它僅適用於主要的導航鏈接塊。一般來說 {{HTMLElement("footer")}} 元素常常有一個不需要在 {{HTMLElement("nav")}} 元素裡面的的鏈接列表。</li> <li>文件可以有很多個 {{HTMLElement("nav")}} 元素。例如說,一個用做網站導覽、另一個用做頁內導覽。</li> <li>面向身障用戶的螢幕閱讀器的用戶代理(User agent),可以決定要不要在初始渲染時省略這個元素的內容。</li> </ul> <h2 id="範例">範例</h2> <p>在這個範例,<code><nav></code> 區塊用於包含連結的無序清單 ({{HTMLElement("ul")}})。透過合適的 CSS,它能夠顯示為 sidebar、導覽列、以及下拉式選單。</p> <pre class="brush: html"><nav class="menu"> <ul> <li><a href="#">Home</a></li> <li><a href="#">About</a></li> <li><a href="#">Contact</a></li> </ul> </nav> </pre> <h2 id="屬性_2">屬性</h2> <table class="standard-table"> <thead> <tr> <th scope="col">Specification</th> <th scope="col">Status</th> <th scope="col">Comment</th> </tr> </thead> <tbody> <tr> <td>{{SpecName('HTML WHATWG', 'sections.html#the-nav-element', '<nav>')}}</td> <td>{{Spec2('HTML WHATWG')}}</td> <td>No change since latest W3C snapshot.</td> </tr> <tr> <td>{{SpecName('HTML5 W3C', 'sections.html#the-nav-element', '<nav>')}}</td> <td>{{Spec2('HTML5 W3C')}}</td> <td>Initial definition</td> </tr> </tbody> </table> <h2 id="瀏覽器相容性">瀏覽器相容性</h2> <p>{{Compat("html.elements.nav")}}</p> <h2 id="參見">參見</h2> <ul> <li>Other section-related elements: {{HTMLElement("body")}}, {{HTMLElement("article")}}, {{HTMLElement("section")}}, {{HTMLElement("aside")}}, {{HTMLElement("h1")}}, {{HTMLElement("h2")}}, {{HTMLElement("h3")}}, {{HTMLElement("h4")}}, {{HTMLElement("h5")}}, {{HTMLElement("h6")}}, {{HTMLElement("hgroup")}}, {{HTMLElement("header")}}, {{HTMLElement("footer")}}, {{HTMLElement("address")}};</li> <li class="last"><a class="deki-ns current" href="/en-US/docs/Sections_and_Outlines_of_an_HTML5_document" title="Sections and Outlines of an HTML5 document">Sections and outlines of an HTML5 document</a>.</li> </ul>