The <button> element is an interactive control users activate with a mouse, keyboard, touch, or assistive technology. It can submit a <form>, reset fields, or run a scripted action.
Set type explicitly: submit, reset, or button. Prefer <button> over <a href="#"> for actions, and over <input type="button"> when you need richer content inside the control.
Baseline · Widely available.
Not deprecated. Core button support has been stable across modern browsers since about July 2015. Some newer attributes (command / popover) have varying support.
Default type can submit.
Inside a form, omitting type means submit. Set type="button" for custom actions that must not send the form.
Newer APIs.
command / commandfor and popovertarget control dialogs and popovers declaratively — useful, but check browser support before relying on them alone.
Syntax
HTML Syntax
syntax.html
<button type="button|submit|reset">label</button>
Both start and end tags are required. Put a clear label between them. Do not nest interactive content (links, other buttons, inputs) inside a button.
Reference
Attributes
The attributes you will use most often on <button>:
Add the disabled attribute (Boolean — no value required).
User cannot activate or focus the disabled control.
It is not successful for form submission.
Toggle in script when your UI rules change (e.g. after validation).
Edge Cases & Pitfalls
Most button bugs are wrong type, fake links, or missing accessible names.
forms
Forgotten type="button"
Inside a form, a bare <button> submits. Set type="button" for non-submit actions.
semantics
Do not fake buttons with <a href="#">
Links navigate. Actions belong on <button> (MDN guidance).
a11y
Icon-only needs a name
Include visible text or an accessible name. Aim for about 44×44 CSS pixels minimum target size.
nesting
No nested interactive content
Do not put links, inputs, or other buttons inside a button.
reset
type="reset" surprises users
Reset clears fields. Use sparingly — people often activate it by mistake.
Compatibility
Browser Support
The <button> element is core HTML in every browser. It is not a Node.js, Deno, or Bun API.
✓ Baseline · Widely available
<button>
Widely available since about July 2015. type, disabled, and form association work everywhere. Popover/command features vary by browser.
98%Global support (approx.)
Google ChromeAll
Full support
Mozilla FirefoxAll
Full support
Apple SafariAll
Full support
Microsoft EdgeAll
Full support
OperaAll
Full support
Samsung InternetAll
Full support
Internet ExplorerAll
Supported
<button>Widely supported
Bottom line: Safe for everyday UI. Use type carefully in forms; treat newer command/popover attributes as progressive enhancement.
Remember
Key Takeaways
Role:<button> is for actions; <a> is for navigation.
type: set button, submit, or reset on purpose.
Label: visible text (or accessible name) must describe the action.
disabled: blocks interaction and focus when the control is not usable.
One line: use <button type="…"> with a clear label for real actions.
UA style
Default CSS Settings
Browsers style buttons like platform controls. Modern engines often treat them as a flow-root box that centers content:
default.css
button {
display: flow-root; /* typical modern UA behavior */
appearance: auto; /* platform look */
/* padding / border / font come from the UA stylesheet */
}
button:disabled {
opacity: 0.6; /* approximate; exact styles vary */
cursor: default;
}
You can fully restyle buttons with CSS. Keep focus styles visible for keyboard users.
Frequently Asked Questions
The button element creates an interactive control users activate with a mouse, keyboard, touch, or assistive technology — for example to submit a form, reset fields, or run a scripted action.
Inside a form, the default type is submit. Always set type="button" when the control should not submit the form.
Use a for navigation to a real URL. Use button for actions on the current page. Do not fake buttons with href="#".
disabled prevents pressing and focusing the button. It is not submitted with the form.
Usually yes. button can contain text, icons, and richer HTML, and is easier to style than input.
Yes. Visible text (or an accessible name via aria-label when needed) must describe the action. Icon-only buttons still need a name for screen readers.