HTML CSS Bootstrap Javascript Icons Python
HTML References
HTML - Tag Reference HTML - Tag by Category HTML - Attributes HTML - Global Attributes HTML - Events HTML - Language Codes HTML - Country Codes HTML - URL Encoding HTTP Methods HTTP Status Codes <input> types
All HTML Tags
<!-- --> <!DOCTYPE> <a> <abbr> <acronym> <address> <applet> <area> <article> <aside> <audio> <b> <base> <basefont> <bdi> <bdo> <big> <blockquote> <body> <br> <button> <canvas> <caption> <center> <cite> <code> <col> <colgroup> <data> <datalist> <dd> <del> <details> <dfn> <dialog> <dir> <div> <dl> <dt> <em> <embed> <fieldset> <figcaption> <figure> <font> <footer> <form> <frame> <frameset> <h1> - <h6> <head> <header> <hr> <html> <i> <iframe> <img> <input> <ins> <kbd> <label> <legend> <li> <link> <main> <map> <mark> <meta> <meter> <nav> <noframes> <noscript> <object> <ol> <optgroup> <option> <output> <p> <param> <picture> <pre> <progress> <q> <rp> <rt> <ruby> <s> <samp> <script> <section> <select> <small> <source> <span> <strike> <strong> <style> <sub> <summary> <sup> <svg> <table> <tbody> <td> <template> <textarea> <tfoot> <th> <thead> <time> <title> <tr> <track> <tt> <u> <ul> <var> <video> <wbr>

HTML <button> tag

The HTML <button> element represents a clickable button, which can be used in forms or anywhere in a document that needs simple, standard button functionality.

While creating a button within HTML form you can also use <input> tag to create similar buttons.

Run code

The button can be programmed to control custom functionality using JavaScript.

By default, HTML buttons are typically presented in a style similar to that of the host platform the browser is running on, but you can change the appearance of the button using CSS. (See Examples below)

Browser compatibility

The <button> element is fully supported by all browsers:

Element
<button> yes yes yes yes yes



Attributes

The following table shows the attributes that are specific to the <button> tag:

HTML5 is new in HTML5

Attribute Value Description
autofocus - Specifies that a button should automatically get focus when the page loads
disabled - Specifies that a button should be disabled
form id Specifies one or more forms the button belongs to
formaction URL Specifies where to send the form-data when a form is submitted. Only for type="submit"
formenctype application/x-www-form-urlencoded
multipart/form-data
text/plain
Specifies how form-data should be encoded before sending it to a server. Only for type="submit"
formmethod get
post
Specifies how to send the form-data (which HTTP method to use). Only for type="submit"
formnovalidate formnovalidate Specifies that the form-data should not be validated on submission. Only for type="submit"
formtarget _blank
_self
_parent
_top
framename
Specifies where to display the response after submitting the form. Only for type="submit"
name string Specifies a name for the button
type button
reset
submit
Specifies the type of button
value text Specifies an initial value for the button

Global Attributes

The <button> tag supports the global attributes described in HTML Global Attributes Reference

Event Attributes

The <button> tag supports the event attributes described in HTML Events Reference


More Examples

The following example shows how you can style buttons using CSS:

Run code

Last updated: Tuesday 18 Sep, 2018