On this page
<button>
Prev: `<input>` | Up: forms | Next: `<textarea>`
Rel: forms, Forms & Inputs Guide
Ref: MDN Web Docs — <button>
Tags: #public #web #html #elements #forms #tier/core
Summary
Clickable action control with built-in keyboard activation (Enter/Space).
- Implicit ARIA Role:
button - DOM Interface:
HTMLButtonElement - Key Attributes:
type, disabled, popovertarget
Notes & Best Practices
- Always specify
type="button"inside<form>unless the button should submit the form (the defaulttypeis"submit"!). - Prefer
<button>over<div onclick>: Built-in focusability,Enter/Spaceactivation, anddisabledsemantics.
Example
<form action="/save" method="post">
<button type="button" id="cancel">Cancel</button>
<button type="submit">Save</button>
</form>
Linked from
Related notes
- tuts/html/elements/forms/input Linked here; links to this page; shared tags: #elements, #forms, #html, #tier, #web
- tuts/html/elements/forms/textarea Linked here; links to this page; shared tags: #elements, #forms, #html, #tier, #web
- tuts/html/elements/forms Linked here; links to this page; shared tags: #elements, #forms, #html, #web
- tuts/html/elements/forms_and_inputs Linked here; shared tags: #elements, #forms, #html, #web
- tuts/html/elements/forms/datalist shared tags: #elements, #forms, #html, #tier, #web
- tuts/html/elements/forms/fieldset shared tags: #elements, #forms, #html, #tier, #web
- tuts/html/elements/forms/form shared tags: #elements, #forms, #html, #tier, #web
- tuts/html/elements/forms/label shared tags: #elements, #forms, #html, #tier, #web
- tuts/html/elements/forms/output shared tags: #elements, #forms, #html, #tier, #web
- tuts/html/elements/forms/select shared tags: #elements, #forms, #html, #tier, #web