Skip to main content

html-tags.com

<button>

A button — focusable, keyboard-activatable, screen-reader-announced, for free.

Baseline: Widely available · Forms

When to use it

Always with an explicit type: submit, reset, or button; also the invoker for popovers via popovertarget and commands via commandfor.

When not to

Never a div or a with onclick pretending to be a button; never omit type inside forms (default is submit).

Key attributes

type
submit | reset | button
popovertarget
opens/closes a popover
disabled
form
associate with a form by id

Example

A popover, no JavaScript involved.

<button type='button' popovertarget='hint'>What does this mean?</button>
<div id='hint' popover><p>A popover, no JavaScript involved.</p></div>
Rendered live above, source below.

Authoritative references