- HTML 教程
- HTML 5简介
- HTML 5 视频
- HTML 5 音频
- HTML 5 Canvas
- HTML 5 Web 存储
- HTML 5 Input 类型
- HTML 5 表单元素
- HTML 5 表单属性
- HTML 5 参考手册
- HTML 5 标准事件属性
- <!-->
- <!DOCTYPE>
- <abbr>
- <acronym>
- <address>
- <applet>
- <area>
- <article>
- <aside>
- <audio>
- <b>
- <base>
- <basefont>
- <bdo>
- <blockquote>
- <body>
- <br />
- <button>
- <canvas>
- <caption>
- <center>
- <em> <strong> <dfn> <code> <samp> <kbd> <var> <cite> 标签
- <col>
- <colgroup>
- <command>
- <datalist>
- <dd>
- <del>
- <details>
- <dir>
- <div>
- <dl>
- <dt>
- <embed>
- <fieldset>
- <figcaption>
- <figure>
- <font>
- <footer>
- <form>
- <frame>
- <frameset>
- <h1> 至 <h6>
- <head>
- <header>
- <hgroup>
- <hr>
- <html>
- <i>
- <iframe>
- <img>
- <input>
- <ins>
- <keygen>
- <em> <strong> <dfn> <code> <samp> <kbd> <var> <cite>
- <label>
- <legend>
- <li>
- <link>
- <map>
- <mark>
- <menu>
- <meta>
- <meter>
- <nav>
- <noframes>
- <object>
- <ol>
- <optgroup>
- <option>
- <output>
- <p>
- <param>
- <pre>
- <progress>
- <q>
- <rp>
- <rt>
- <ruby>
- <s>
- <script>
- <section>
- <select>
- <small>
- <source>
- <span>
- <strike>
- <style>
- <sub> 和 <sup>
- <summary>
- <table>
- <tbody>
- <td>
- <textarea>
- <tfoot>
- <th>
- <thead>
- <time>
- <title>
- <tr>
- <tt>
- <u>
- <ul>
- <video>
定义和用法
<button> 标签定义按钮。
您可以在 button 元素放置内容,比如文本或图像。这是该元素与通过 input 元素创建的按钮的不同之处。
请始终为按钮规定 type 属性。不同的浏览器根据 type 属性使用不同的默认值。
实例
标记一个按钮:
<button type="button">Click Me!</button>
亲自试一试
HTML 4.01 与 HTML 5 之间的差异
HTML 5 中的新属性:autofocus, form, formaction, formenctype, formmethod, formnovalidate 以及 formtarget。
提示和注释
注释:如果在 HTML 表单中使用 button 元素,不同的浏览器会提交不同的按钮值。请使用 input 元素在HTML 表单中创建按钮。
属性
属性 | 值 | 描述 |
autofocusNew | autofocus | 如果设置,则当页面加载后使按钮获得焦点。 |
disabled | disabled | 禁用按钮。 |
formNew | form_name | 规定按钮属于哪个表单。 |
formactionNew | url | 规定当提交表单时向何处提交表单数据。 覆盖表单的 action 属性。 |
formenctypeNew | 见注释 | 规定如何在表单数据发送到服务器之前如何进行编码。 覆盖表单的 enctype 属性。 |
formmethodNew | delete get post put | 规定如何发送表单数据。 覆盖表单的 method 属性。 |
formnovalidateNew | formnovalidate | 如果设置,指示是否在提交时验证表单。 覆盖表单的 novalidate 属性。 |
formtargetNew | _blank _self _parent _top framename | 规定在何处打开 action 中的 URL。 覆盖表单的 target 属性。 |
name | button_name | 规定按钮的名称。 |
type | Button reset submit | 定义按钮的类型。 |
value | some_value | 规定按钮的初始值。可由脚本进行修改。 |
注释:formenctypeNew 属性可能的值:
application/x-www-form-urlencoded
multipart/form-data
text/plain
标准属性
<button> 标签支持 HTML 5 中的标准属性。
事件属性
<button> 标签支持 HTML 5 中的事件属性。