# HTML <button> 標簽
## 實例
以下代碼標記了一個按鈕:
```
<button type="button">Click Me!</button>
```
## 瀏覽器支持
| IE | Firefox | Chrome | Safari | Opera |
| --- | --- | --- | --- | --- |
所有主流瀏覽器都支持 <button> 標簽。
重要事項:如果在 HTML 表單中使用 button 元素,不同的瀏覽器會提交不同的值。Internet Explorer 將提交 <button> 與 <button/> 之間的文本,而其他瀏覽器將提交 value 屬性的內容。請在 HTML 表單中使用 [input 元素](/tags/tag_input.asp "HTML <input> 標簽")來創建按鈕。
## 定義和用法
<button> 標簽定義一個按鈕。
在 button 元素內部,您可以放置內容,比如文本或圖像。這是該元素與使用 input 元素創建的按鈕之間的不同之處。
<button> 控件 與 <input type="button"> 相比,提供了更為強大的功能和更豐富的內容。<button> 與 </button> 標簽之間的所有內容都是按鈕的內容,其中包括任何可接受的正文內容,比如文本或多媒體內容。例如,我們可以在按鈕中包括一個圖像和相關的文本,用它們在按鈕中創建一個吸引人的標記圖像。
唯一禁止使用的元素是圖像映射,因為它對鼠標和鍵盤敏感的動作會干擾表單按鈕的行為。
請始終為按鈕規定 type 屬性。Internet Explorer 的默認類型是 "button",而其他瀏覽器中(包括 W3C 規范)的默認值是 "submit"。
## HTML 4.01 與 HTML 5 之間的差異
HTML 5 中的新屬性:autofocus, form, formaction, formenctype, formmethod, formnovalidate 以及 formtarget。
## 提示和注釋
注釋:如果在 HTML 表單中使用 button 元素,不同的瀏覽器會提交不同的按鈕值。請使用 [input 元素](/tags/tag_input.asp "HTML 5 <input> 標簽")在 HTML 表單中創建按鈕。
## 屬性
new : HTML5 中的新屬性。
| 屬性 | 值 | 描述 |
| --- | --- | --- |
| [autofocus](/tags/att_button_autofocus.asp "HTML5 <button> autofocus 屬性") | autofocus | 規定當頁面加載時按鈕應當自動地獲得焦點。 |
| [disabled](/tags/att_button_disabled.asp "HTML5 <button> disabled 屬性") | disabled | 規定應該禁用該按鈕。 |
| [form](/tags/att_button_form.asp "HTML5 <button> form 屬性") | *form_name* | 規定按鈕屬于一個或多個表單。 |
| [formaction](/tags/att_button_formaction.asp "HTML5 <button> formaction 屬性") | _url_ |覆蓋 form 元素的 action 屬性。注釋:該屬性與 type="submit" 配合使用。 |
| [formenctype](/tags/att_button_formenctype.asp "HTML5 <button> formenctype 屬性") | 見注釋 |覆蓋 form 元素的 enctype 屬性。注釋:該屬性與 type="submit" 配合使用。 |
| [formmethod](/tags/att_button_formmethod.asp "HTML5 <button> formmethod 屬性") | `get` `post` |覆蓋 form 元素的 method 屬性。注釋:該屬性與 type="submit" 配合使用。 |
| [formnovalidate](/tags/att_button_formnovalidate.asp "HTML5 <button> formnovalidate 屬性") | formnovalidate |覆蓋 form 元素的 novalidate 屬性。注釋:該屬性與 type="submit" 配合使用。 |
| [formtarget](/tags/att_button_formtarget.asp "HTML5 <button> formtarget 屬性") | `_blank` `_self` `_parent` `_top` `framename` |覆蓋 form 元素的 target 屬性。注釋:該屬性與 type="submit" 配合使用。 |
| [name](/tags/att_button_name.asp "HTML5 <button> name 屬性") | *button_name* | 規定按鈕的名稱。 |
| [type](/tags/att_button_type.asp "HTML5 <button> type 屬性") | `button` `reset` `submit` | 規定按鈕的類型。 |
| [value](/tags/att_button_value.asp "HTML5 <button> value 屬性") | _text_ | 規定按鈕的初始值。可由腳本進行修改。 |
注釋:formenctype 屬性可能的值:
* application/x-www-form-urlencoded
* multipart/form-data
* text/plain
## 全局屬性
<button> 標簽支持 [HTML 中的全局屬性](/tags/html_ref_standardattributes.asp)。
## 事件屬性
<button> 標簽支持 [HTML 中的事件屬性](/tags/html_ref_eventattributes.asp)。
## 相關頁面
HTML DOM 參考手冊:[Button 對象](/jsref/dom_obj_pushbutton.asp "HTML DOM Button 對象")
- HTML 標簽列表
- HTML <!--...--> 標簽
- HTML <!DOCTYPE> 標簽
- HTML <a> 標簽
- HTML <abbr> 標簽
- HTML <acronym> 標簽
- HTML <address> 標簽
- HTML <applet> 標簽
- HTML <area> 標簽
- HTML <article> 標簽
- HTML <aside> 標簽
- HTML <audio> 標簽
- HTML <b> 標簽
- HTML <base> 標簽
- HTML <basefont> 標簽
- HTML <bdi> 標簽
- HTML <bdo> 標簽
- HTML <big> 標簽
- HTML <blockquote> 標簽
- HTML <body> 標簽
- HTML <br> 標簽
- HTML <button> 標簽
- HTML <canvas> 標簽
- HTML <caption> 標簽
- HTML <center> 標簽
- HTML <cite> 標簽
- HTML <em> <strong> <dfn> <code> <samp> <kbd><var> <cite> 標簽
- HTML <col> 標簽
- HTML <colgroup> 標簽
- HTML <command> 標簽
- HTML <datalist> 標簽
- HTML <dd> 標簽
- HTML <del> 標簽
- HTML <details> 標簽
- HTML <dialog> 標簽
- HTML <dir> 標簽
- HTML <div> 標簽
- HTML <dl> 標簽
- HTML <dt> 標簽
- HTML <embed> 標簽
- HTML <fieldset> 標簽
- HTML <figcaption> 標簽
- HTML <figure> 標簽
- HTML <font> 標簽
- HTML <footer> 標簽
- HTML <form> 標簽
- HTML <frame> 標簽
- HTML <frameset> 標簽
- HTML <h1> 到 <h6> 標簽
- HTML <head> 標簽
- HTML <header> 標簽
- HTML <hr> 標簽
- HTML <html> 標簽
- HTML <i> 標簽
- HTML <iframe> 標簽
- HTML <img> 標簽
- HTML <input> 標簽
- HTML DOM Button 對象
- HTML DOM Checkbox 對象
- HTML DOM Color 對象
- HTML DOM Input Date 對象
- HTML DOM Datetime 對象
- HTML DOM Datetime Local 對象
- HTML DOM Email 對象
- HTML DOM FileUpload 對象
- HTML DOM Hidden 對象
- HTML DOM Input Image 對象
- HTML DOM Month 對象
- HTML DOM Number 對象
- HTML DOM Password 對象
- HTML DOM Input Range 對象
- HTML DOM Radio 對象
- HTML DOM Reset 對象
- HTML DOM Input Search 對象
- HTML DOM Submit 對象
- HTML DOM Text 對象
- HTML DOM Input Time 對象
- HTML DOM Input URL 對象
- HTML DOM Input Week 對象
- HTML <ins> 標簽
- HTML <keygen> 標簽
- HTML <label> 標簽
- HTML <legend> 標簽
- HTML <li> 標簽
- HTML <link> 標簽
- HTML <main> 標簽
- HTML <map> 標簽
- HTML <mark> 標簽
- HTML <menu> 標簽
- HTML <menuitem> 標簽
- HTML <meta> 標簽
- HTML <meter> 標簽
- HTML <nav> 標簽
- HTML <noframes> 標簽
- HTML <noscript> 標簽
- HTML <object> 標簽
- HTML <ol> 標簽
- HTML <optgroup> 標簽
- HTML <option> 標簽
- HTML <output> 標簽
- HTML <p> 標簽
- HTML <param> 標簽
- HTML <pre> 標簽
- HTML <progress> 標簽
- HTML <q> 標簽
- HTML <rp> 標簽
- HTML <rt> 標簽
- HTML <ruby> 標簽
- HTML <s> 標簽
- HTML <script> 標簽
- HTML <section> 標簽
- HTML <select> 標簽
- HTML <small> 標簽
- HTML <source> 標簽
- HTML <span> 標簽
- HTML <strike> 標簽
- HTML <style> 標簽
- HTML <sub> 標簽
- HTML <summary> 標簽
- HTML <sup> 標簽
- HTML <table> 標簽
- HTML <tbody> 標簽
- HTML <td> 標簽
- HTML <textarea> 標簽
- HTML <tfoot> 標簽
- HTML <th> 標簽
- HTML <thead> 標簽
- HTML <time> 標簽
- HTML <title> 標簽
- HTML <tr> 標簽
- HTML <track> 標簽
- HTML <tt> 標簽
- HTML <u> 標簽
- HTML <ul> 標簽
- HTML <video> 標簽
- HTML <wbr> 標簽
- HTML 全局屬性
- HTML accesskey 屬性
- HTML class 屬性
- HTML contenteditable 屬性
- HTML contextmenu 屬性
- HTML data-* 屬性
- HTML dir 屬性
- HTML draggable 屬性
- HTML dropzone 屬性
- HTML hidden 屬性
- HTML id 屬性
- HTML lang 屬性
- HTML spellcheck 屬性
- HTML style 屬性
- HTML tabindex 屬性
- HTML title 屬性
- HTML translate 屬性
- HTML 事件屬性
- HTML 5 視頻/音頻參考手冊
- HTML 5 Canvas 參考手冊
- HTML 元素和有效的 DTD
- HTML 顏色名
- HTML 字符集
- HTML ASCII 參考手冊
- HTML ISO-8859-1 參考手冊
- HTML 4.01 符號實體
- HTML URL 編碼
- HTML 語言代碼參考手冊
- HTTP 狀態消息
- HTTP 方法:GET 對比 POST
- 免責聲明