Forms & Controls

HTML <button> element

Build a form with the HTML form generator

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

NameTypeDescription
disabledbooleanDisables 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.
formform element IDAssociates 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.
formactionURLOverrides the associated form's submission destination for this submit button or image submit input.
formenctypeform encoding keywordOverrides the associated form's encoding when this submit control initiates submission. Use multipart/form-data for file upload requests.
formmethodenumerated: get, post, dialogOverrides the form submission method for a particular submit control. dialog closes an associated dialog instead of making an ordinary network submission.
formnovalidatebooleanBypasses native constraint validation when the corresponding submit control is used. Server-side validation is still required.
formtargetbrowsing context name or keywordOverrides the target browsing context for the submission initiated by this control.
namestringProvides 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.
typesubmit, reset, buttonControls native button behavior. Set type="button" for a non-submitting control inside a form.
valueelement-dependent text or numberSets 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.
popovertargetelement IDIdentifies a popover controlled by a button or eligible input button. The target must have the popover attribute; use the ID without #.
popovertargetactionenumerated: toggle, show, hideSpecifies the action a popover invoker performs. The default is toggle. The target must be identified by popovertarget.
commandcommand keyword or --custom nameSpecifies 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.
commandforelement IDIdentifies 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
HTML Reference