<button>
A button: submits a form or triggers an action.
Syntax
<button type="button">Text</button>Attributes
| Parameter | Type | Description |
|---|---|---|
| type | submit | button | reset | What the button does. Inside a form the default is `submit`. |
| disabled | — | Optional. The button is disabled. |
| popovertarget | id | Optional. Open or close the popover with this `id`. |
Examples
Form buttons:
<form>
<input name="q" placeholder="Search">
<button type="submit">Find</button>
<button type="reset">Clear</button>
</form>A button that triggers an action:
<button type="button" onclick="this.textContent = 'Thanks!'">Click me</button>
<button disabled>Not available</button>Notes
Inside a form a button without type submits the form — a common cause of unexpected reloads. For buttons that do not submit, write type="button". Unlike <input type="submit">, a <button> can contain an icon or other markup.
See also
Related recipes
In the tutorial
- Buttons — The button tag and its submit, reset and button types, a button with an icon, a disabled button and the difference between a button and a link.