The <button> tag

The <button> tag creates a clickable button. Its behavior depends on the type attribute, especially inside a <form>.

Syntax

<button type="button">Button text</button>

Attributes

type "submit" (the form default) submits the form; "button" does nothing automatically; "reset" clears the form.
disabled Makes the button inactive and unfocusable/unclickable.
name / value If the button is inside a form, these values are included in the submitted form data when that specific button triggers submission.

Example

<button type="submit">Submit</button>
<button type="button" onclick="doSomething()">Just an action</button>

Notes

  • The most common mistake: a button inside a <form> without type="button" accidentally submits the form on click.
  • Use <button> rather than a clickable div/span to get keyboard accessibility and semantics for free.

Accessibility

  • button is already Tab-focusable and Enter/Space-activatable out of the box — unlike a div/span.

Related tools