aboutsummaryrefslogtreecommitdiff
path: root/files/zh-tw/web/html/element/nav/index.html
blob: 114fc8e9198dccaaef0d44ece8fc9addc0f1977c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
---
title: <nav>
slug: Web/HTML/Element/nav
tags:
  - 元素
  - 區域
  - 導航欄
  - 網站
  - 網站區域
  - 網頁
  - 網頁區域
  - 連結
translation_of: Web/HTML/Element/nav
---
<div>{{HTMLRef}}</div>

<p><span class="seoSummary"><strong>HTML &lt;nav&gt; 元素</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>&lt;nav&gt;</code> 元素裡面,它僅適用於主要的導航鏈接塊。一般來說 {{HTMLElement("footer")}} 元素常常有一個不需要在 {{HTMLElement("nav")}} 元素裡面的的鏈接列表。</li>
 <li>文件可以有很多個 {{HTMLElement("nav")}} 元素。例如說,一個用做網站導覽、另一個用做頁內導覽。</li>
 <li>面向身障用戶的螢幕閱讀器的用戶代理(User agent),可以決定要不要在初始渲染時省略這個元素的內容。</li>
</ul>

<h2 id="範例">範例</h2>

<p>在這個範例,<code>&lt;nav&gt;</code> 區塊用於包含連結的無序清單 ({{HTMLElement("ul")}})。透過合適的 CSS,它能夠顯示為 sidebar、導覽列、以及下拉式選單。</p>

<pre class="brush: html">&lt;nav class="menu"&gt;
  &lt;ul&gt;
    &lt;li&gt;&lt;a href="#"&gt;Home&lt;/a&gt;&lt;/li&gt;
    &lt;li&gt;&lt;a href="#"&gt;About&lt;/a&gt;&lt;/li&gt;
    &lt;li&gt;&lt;a href="#"&gt;Contact&lt;/a&gt;&lt;/li&gt;
  &lt;/ul&gt;
&lt;/nav&gt;
</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', '&lt;nav&gt;')}}</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', '&lt;nav&gt;')}}</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>