HTML Essentials
Buttons
Create actions with explicit button behavior.
The button element triggers an action. Inside a form, its type determines whether it submits, resets, or performs a custom action.
Important definitions
- Submit button
- Sends its form.
- Button type
- A neutral button for scripted behavior.
Syntax
Use this general pattern as a reference:
HTML
<button type="button">Label</button>Examples
Buttons worked example
EXAMPLE 1
<button type="button">Open menu</button>ResultA clickable button labeled Open menu.
COMPLETE EXAMPLE
<button type="button">Open menu</button>Expected output
A clickable button labeled Open menu.
Note
A button can contain text and simple inline elements.
Tip
Always state the type, especially inside forms.
Common mistakes
- Using a link for an in-page action.
- Leaving the default submit behavior accidental.