Forms & Inputs
HTML <button> Tag
The <button> tag defines a clickable button.
Definition and Usage
The <button> tag defines a clickable button.
Standard Syntax:
<button>...</button>Interactive ExampleRunnable
HTML <button> Example
htmlLive code demonstration for the <button> tag. Click "Try it Yourself" to edit and experiment in real time.
<div style="font-family: system-ui, sans-serif; padding: 16px; background: #ffffff; border-radius: 8px; border: 1px solid #e2e8f0; color: #0f172a;">
<button type="button">Click Me!</button>
</div>Attributes for <button>
14 Supported Attributes| Attribute | Values | Default | Description |
|---|---|---|---|
| autofocus | autofocus | none | Specifies that a button should automatically get focus when the page loads |
| disabled | disabled | none | Specifies that a button should be disabled |
| command | show-modalcloserequest-closeshow-popoverhide-popover toggle-popover--custom-value | none | Specifies the action to be performed |
| commandfor | string | none | Turns the button into a command button |
| form | form_id | none | Specifies which form the button belongs to |
| formaction | URL | none | 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 | none | Specifies how form-data should be encoded before sending it to a server. Only for type="submit" |
| formmethod | getpost | none | Specifies how to send the form-data (which HTTP method to use). Only for type="submit" |
| formnovalidate | formnovalidate | none | Specifies that the form-data should not be validated on submission. Only for type="submit" |
| formtarget | _blank _self _parent _top framename | none | Specifies where to display the response after submitting the form. Only for type="submit" |
| name | name | none | Specifies a name for the button |
| popovertarget | element_id | none | Specifies which popover element to invoke |
| popovertargetaction | hideshowtoggle | none | Specifies what happens to the targeted popover element when you click the button |
| type | button reset submit | none | Specifies the type of button |
Global Attributes
The <button> tag also supports the standard global attributes in HTML, including class, id, style, title, hidden, and data-*.
Event Attributes
The <button> tag supports event attributes in HTML, such as onclick, onmouseover, onfocus, and more.
Browser Compatibility
ChromeEdgeFirefoxSafariOpera
More Tags in Forms & Inputs
View All 123Tags →<datalist>The <datalist> tag specifies a list of pre-defined options for an <input> element.<fieldset>The <fieldset> tag is used to group related elements in a form.<form>The <form> tag is used to create an HTML form for user input.<input>The <input> tag specifies an input field where the user can enter data.<label>The <label> tag defines a label for several elements:<legend>The <legend> tag defines a caption for the <fieldset> element.