Menu
Forms & Inputs

<button> Tag

Submit forms or trigger JavaScript actions.

1Pick a Type

type="submit" submits the parent form, type="reset" clears it, type="button" does nothing by default — wire it up with JavaScript. Always set a type to avoid surprises.

Example Code
css
<button type="submit">Save</button>
<button type="reset">Clear</button>
<button type="button" onclick="openModal()">Open modal</button>

<button type="submit" disabled>Submitting…</button>

2Put the element in context

A button performs an action and has native interaction behavior. Inside a form, its default type can submit, so set type deliberately. A link styled as a button is still suitable for navigation; do not remove its actual destination to imitate an action control.

3Practice with a small page

Add a submit button and a separate type="button" preview action to a form. Test both with the keyboard and confirm that only the intended control submits. Give every button a clear label and a visible focus state.

Finished reading?

Mark this topic as complete to track progress.