| 屬性 | 值/類型 | 說明 | 預設/備註 |
|---|---|---|---|
| type | submit | reset | button | 表單提交/重置/無預設行為 | submit (表單內) / button (表單外) — 務必顯式指定 |
| disabled | boolean | 禁用:不可聚焦、不提交、不觸發 click、樣式灰化 | false |
| form | form id | 關聯表單 (可置於 form 外部) | 最近祖先 form |
| formaction | URL | 覆蓋 form action (type=submit) | -- |
| formenctype | multipart/form-data | application/x-www-form-urlencoded | text/plain | 覆蓋 form enctype | -- |
| formmethod | get | post | dialog | 覆蓋 form method | -- |
| formnovalidate | boolean | 跳過驗證提交 | false |
| formtarget | _blank | _self | _parent | _top | framename | 覆蓋 form target | -- |
| name | string | 提交時作為鍵值對 (name=value) | -- |
| value | string | 提交值 (同 name 按鈕只提交被點擊者) | -- |
| autofocus | boolean | 頁面載入自動聚焦 (每頁僅一個) | false |
| popover | auto | manual | HTML Popover API 觸發器 (實驗中) | -- |
| popovertarget | element id | 目標 popover 元素 id | -- |
| popovertargetaction | toggle | show | hide | 動作類型 | toggle |
| command | string | Command API 指令識別 (實驗中) | -- |
| commandfor | element id | 目標命令元素 | -- |
<form action="/submit" method="post">
<input name="q">
<button type="submit">送出</button> <!-- 觸發 form submit -->
<button type="reset">重置</button> <!-- 重置表單欄位 -->
<button type="button" onclick="doSomething()">動作</button> <!-- 僅 JS -->
</form>
陷阱:在 <form> 內無 type 的 <button> 等同 type="submit",易造成非預期提交。
<form id="search-form" action="/search" method="get">
<input name="q" placeholder="關鍵字">
</form>
<button type="submit" form="search-form" formaction="/search-advanced" formmethod="post">
進階搜尋
</button>
disabled 會自動從無障礙樹移除、不可聚焦;若需保持可聚焦但禁用,改用 aria-disabled="true" + CSS pointer-events:none; opacity:0.5;aria-label 或內含 <span class="sr-only">文字</span>type="button" 的按鈕在表單外不會觸發任何原生行為,適合 JS 綁定<button popovertarget="my-popover">開啟</button> + <div id="my-popover" popover>內容</div> — 無 JS 實現彈出層<button commandfor="cmd-save"> 統一命令來源 (菜單/快捷鍵/工具列共用)<button command="copy">