The button Element submit reset button
Trigger form submission, reset, or custom actions with buttons.
The button Element submit reset button is a free HTML Academy lesson on CoddyKit — lesson 4 of 4. You can read the complete lesson below for free — then practise it hands-on in the browser with a built-in code editor and a 24/7 AI tutor. It is part of the HTML Academy learning path, one of 4 lessons in the course, and your progress syncs across the web and the CoddyKit app.
The button Element
The <button> element is the primary way to create clickable controls:
<button type="submit">Submit</button>
<button type="reset">Clear Form</button>
<button type="button">Do Something</button>
<!-- Three types, each with a different default behavior -->
<!-- Always specify type — the default is submit inside forms -->type=submit
type="submit" submits the form when clicked:
<form action="/register" method="post">
<input type="email" name="email">
<button type="submit">Create Account</button>
</form>
<!-- Triggers form validation, then sends the form data -->
<!-- Also triggered by pressing Enter in most text inputs -->type=reset
type="reset" clears all form fields to their default values:
<form>
<input type="text" name="name" value=""> <!-- empty default -->
<input type="number" name="qty" value="1"> <!-- default: 1 -->
<button type="reset">Clear</button>
</form>
<!-- Clicking reset restores qty to 1 and clears name -->
<!-- Use sparingly — users often accidentally reset forms -->type=button
type="button" does nothing by default — attach JavaScript:
<button type="button" id="toggle-theme">Toggle Dark Mode</button>
<script>
document.getElementById('toggle-theme').addEventListener('click', () => {
document.body.classList.toggle('dark');
});
</script>
<!-- type="button" prevents accidental form submission
Always use this for non-submit buttons -->button vs input[type=submit]
<button> is preferred over <input type="submit">:
<!-- Old way (limited): -->
<input type="submit" value="Submit">
<!-- Modern way (flexible — can contain HTML): -->
<button type="submit">
<svg><!-- icon --></svg>
Submit Form
</button>
<!-- button can contain icons, emphasis, and any inline HTML
input type=submit can only have plain text via the value attribute -->Disabled Button
Disable a button with the disabled attribute:
<button type="submit" disabled>Submit</button>
<!-- Disabled buttons:
- Cannot be clicked
- Not in tab order
- NOT submitted with the form
- Browser renders them grayed out -->
<!-- Enable/disable with JavaScript: -->
btn.disabled = true;
btn.disabled = false;Loading State Pattern
Show loading state while a form is being submitted:
<button type="submit" id="submit-btn">
<span id="btn-text">Submit</span>
<span id="btn-spinner" hidden aria-hidden="true">⏳</span>
</button>
<script>
form.addEventListener('submit', () => {
document.getElementById('submit-btn').disabled = true;
document.getElementById('btn-text').textContent = 'Submitting...';
document.getElementById('btn-spinner').hidden = false;
document.getElementById('btn-spinner').removeAttribute('aria-hidden');
});
</script>formaction and formmethod Overrides
Override form action/method on a specific button:
<form action="/save" method="post">
<input type="text" name="title">
<!-- Save: uses form defaults -->
<button type="submit">Save Draft</button>
<!-- Publish: overrides action and method -->
<button type="submit" formaction="/publish" formmethod="post">
Publish Now
</button>
</form>Button with ARIA
Custom buttons need ARIA if they look different from native buttons:
<!-- Icon-only button -->
<button type="button" aria-label="Close dialog">
<svg aria-hidden="true"><!-- X icon --></svg>
</button>
<!-- Toggle button -->
<button type="button" aria-pressed="false" id="bold-btn">
Bold
</button>
<script>
document.getElementById('bold-btn').addEventListener('click', function() {
const pressed = this.getAttribute('aria-pressed') === 'true';
this.setAttribute('aria-pressed', !pressed);
});
</script>Button Accessibility Best Practices
Button accessibility checklist:
- Always specify
type— never rely on the default - Use
aria-labelfor icon-only buttons - Use
aria-pressedfor toggle buttons - Disabled buttons: consider using
aria-disabled="true"+ JavaScript to keep them focusable - Never use
<div>or<span>as buttons
Click Area and Touch Targets
Buttons must have sufficient tap target size for touch users:
button {
min-height: 44px; /* Apple HIG minimum */
min-width: 44px; /* WCAG 2.5.5 (AAA) recommends 44x44 -->
padding: 0.5rem 1rem;
cursor: pointer;
}
/* Increase tap area without changing visual size: */
button {
position: relative;
}
button::before {
content: '';
position: absolute;
inset: -8px;
}Quick Check
What happens if you omit the type attribute on a button inside a form?
Recap: button Element
Button essentials:
type="submit"— submits the formtype="reset"— resets all fields to defaultstype="button"— no default behavior; attach JavaScript- Always specify type — default is submit
- Prefer
<button>over<input type="submit"> - Use
aria-labelfor icon-only buttons
Frequently asked questions
Is the “The button Element submit reset button” lesson free?
Yes — the full text of “The button Element submit reset button” is free to read here on the web, and the HTML Academy course includes 4 lessons in total. To practise it interactively (a built-in code editor and a 24/7 AI tutor) and unlock the rest of the HTML Academy course, upgrade to CoddyKit PRO.
What will I learn in “The button Element submit reset button”?
Trigger form submission, reset, or custom actions with buttons. You practise HTML Academy with hands-on code you run directly in the browser, and a 24/7 AI tutor answers your questions as you work through the lesson.
Do I need any experience to start HTML Academy?
No prior experience is required. HTML Academy on CoddyKit is structured for beginners through advanced learners; this is — lesson 4 of 4, so you can start here or from the beginning and move at your own pace.
How long does the “The button Element submit reset button” lesson take?
Most CoddyKit lessons take about 5–10 minutes. Each one is bite-sized and interactive, so you make steady progress and pick up exactly where you left off across the web and the app.
Can I write and run code in this HTML Academy lesson?
Yes. Every HTML Academy lesson includes a built-in code editor, so you write and run real code right in your browser and get instant AI feedback — no local setup required.
All lessons in this course
- The form Element action method enctype
- Input Types text password email number tel
- The label Element and Accessibility
- The button Element submit reset button