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

html
Try it Yourself
Live 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
AttributeValuesDefaultDescription
autofocusautofocusnoneSpecifies that a button should automatically get focus when the page loads
disableddisablednoneSpecifies that a button should be disabled
commandshow-modalcloserequest-closeshow-popoverhide-popover toggle-popover--custom-valuenoneSpecifies the action to be performed
commandforstringnoneTurns the button into a command button
formform_idnoneSpecifies which form the button belongs to
formactionURLnoneSpecifies where to send the form-data when a form is submitted. Only for type="submit"
formenctypeapplication/x-www-form-urlencoded multipart/form-data text/plainnoneSpecifies how form-data should be encoded before sending it to a server. Only for type="submit"
formmethodgetpostnoneSpecifies how to send the form-data (which HTTP method to use). Only for type="submit"
formnovalidateformnovalidatenoneSpecifies that the form-data should not be validated on submission. Only for type="submit"
formtarget_blank _self _parent _top framenamenoneSpecifies where to display the response after submitting the form. Only for type="submit"
namenamenoneSpecifies a name for the button
popovertargetelement_idnoneSpecifies which popover element to invoke
popovertargetactionhideshowtogglenoneSpecifies what happens to the targeted popover element when you click the button
typebutton reset submitnoneSpecifies 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-*.

HTML Global Attributes Reference →
Event Attributes

The <button> tag supports event attributes in HTML, such as onclick, onmouseover, onfocus, and more.

HTML Event Attributes Reference →

Browser Compatibility

ChromeEdgeFirefoxSafariOpera

More Tags in Forms & Inputs

View All 123Tags →