Forms & Controls
HTML <button> element
Represents an interactive button. Specify type="button" for non-submitting actions within forms; submit buttons can initiate form submission. Inside a form, explicitly set type="button" for actions that must not submit. Native buttons support keyboard activation; use visible text or an accessible name for icon buttons. Submit buttons may override form submission settings. Avoid interactive descendants. It accepts global HTML attributes; individual global features may be inapplicable or restricted.
Formal Syntax & Structure
html syntaxhtml
<button type="button">Action</button>Parameters & Attributes
| Name | Type | Description |
|---|---|---|
| disabled | boolean | Disables supported controls or elements. Disabled form controls are generally not focusable, validated or submitted. The exact effect depends on the element; disabled="false" still disables. |
| form | form element ID | Associates an eligible control with a form elsewhere in the same document, overriding an ancestor form where applicable. Does not automatically associate descendants of a fieldset. |
| formaction | URL | Overrides the associated form's submission destination for this submit button or image submit input. |
| formenctype | form encoding keyword | Overrides the associated form's encoding when this submit control initiates submission. Use multipart/form-data for file upload requests. |
| formmethod | enumerated: get, post, dialog | Overrides the form submission method for a particular submit control. dialog closes an associated dialog instead of making an ordinary network submission. |
| formnovalidate | boolean | Bypasses native constraint validation when the corresponding submit control is used. Server-side validation is still required. |
| formtarget | browsing context name or keyword | Overrides the target browsing context for the submission initiated by this control. |
| name | string | Provides an element-specific name: a form field key, radio group name, named frame, metadata key, slot name or other defined purpose. Its meaning depends on the element; it is not a unique DOM identifier. |
| type | submit, reset, button | Controls native button behavior. Set type="button" for a non-submitting control inside a form. |
| value | element-dependent text or number | Sets an initial form value, a submitted option value, a list item ordinal or a numeric meter/progress value depending on the element. Current control state may differ from the content attribute. |
| popovertarget | element ID | Identifies a popover controlled by a button or eligible input button. The target must have the popover attribute; use the ID without #. |
| popovertargetaction | enumerated: toggle, show, hide | Specifies the action a popover invoker performs. The default is toggle. The target must be identified by popovertarget. |
| command | command keyword or --custom name | Specifies an action a button requests on a target named by commandfor. Built-in commands include dialog and popover actions; custom commands use a double-hyphen prefix. Support is feature-dependent. |
| commandfor | element ID | Identifies the target of a button command. Use an ID without a hash and an appropriate command value. Check browser support for declarative commands. |
Return Value
HTMLButtonElement
Content model: Phrasing content, with restrictions on interactive descendants and tabindex; customizable select has additional rules.
Working Example
Example Snippethtml
<!doctype html><html lang="en"> <head> <meta charset="utf-8"> <title>HTML example</title> </head> <body> <button type="button" popovertarget="help">Help</button> <p id="help" popover>Choose a book.</p> </body></html>Browser Compatibility
Minimum supported versions across modern rendering engines
Widely Available
Blink (modern)
Chrome
1
Yes
EdgeHTML / Blink
Edge
12
Yes
Gecko
Firefox
1
Yes
WebKit
Safari
1
Yes
Presto / Blink
Opera
≤15
Yes
Basic button element; command, popover and other newer attributes have separate support.
HTML Living Standard