🚀 LEVEL UP TO SENIOR:Unlock 500+ Advanced Practical Challenges & Exercises.
🎓 COURSERA PARTNER:Earn professional Google, Meta, and IBM certificates to supercharge your resume.
REFERENCEhtml

html Documentation

LOADING ENGINE...

Reset

AI & DATA SCIENCE // reset

A reset control (<button type="reset"> or <input type="reset">) clears every field in the enclosing form back to its original default values.

Syntax

<button type="reset">Clear Form</button>

Deep Dive Course

Clicking a reset control restores every field in the form to whatever value it had when the page first loaded (i.e. whatever was set via `value`, `checked`, or `selected` in the HTML) — it does NOT necessarily clear fields to blank; a field that started pre-filled will return to that pre-filled state, not to empty. This distinction trips up many developers who expect 'reset' to mean 'blank everything'.

1Understanding Reset

Clicking a reset control restores every field in the form to whatever value it had when the page first loaded (i.e. whatever was set via value, checked, or selected in the HTML) — it does NOT necessarily clear fields to blank; a field that started pre-filled will return to that pre-filled state, not to empty. This distinction trips up many developers who expect 'reset' to mean 'blank everything'.

💡

Reset buttons are far less common in modern form design than they used to be — accidentally clicking one can wipe out everything a user just carefully typed, which is a frustrating experience most modern UIs deliberately avoid.

editor.html
<form>
  <input type="text" name="city" value="New York">
  <button type="reset">Reset</button>
</form>
localhost:3000

2Practical Example

Here is a real-world application of Reset showing how it is used in production HTML.

editor.html
<!-- Reset does NOT clear this back to empty — it restores the original checked state -->
<input type="checkbox" name="newsletter" checked>
<button type="reset">Reset</button>
localhost:3000

3Best Practices

Follow these guidelines when working with Reset:

1. Think carefully before including a reset button at all — it's a common source of accidental data loss for users

2. Remember reset restores original HTML default values, not necessarily blank fields

3. If you do include one, style it clearly differently from the submit button to reduce accidental clicks

⚠️

Tip: Reset buttons are far less common in modern form design than they used to be — accidentally clicking one can wipe out everything a user just carefully typed, which is a frustrating experience most modern UIs deliberately avoid.

editor.html
<form>
  <input type="text" name="city" value="New York">
  <button type="reset">Reset</button>
</form>
localhost:3000

Examples

Example 01Basic Usage
<form>
  <input type="text" name="city" value="New York">
  <button type="reset">Reset</button>
</form>
Example 02Advanced Example
<!-- Reset does NOT clear this back to empty — it restores the original checked state -->
<input type="checkbox" name="newsletter" checked>
<button type="reset">Reset</button>

Best Practices

  • Think carefully before including a reset button at all — it's a common source of accidental data loss for users
  • Remember reset restores original HTML default values, not necessarily blank fields
  • If you do include one, style it clearly differently from the submit button to reduce accidental clicks

Interview Question

Does clicking a reset button always clear form fields to empty?

Hint: Think about a text input that had a pre-filled default value in the HTML.

No — reset restores every field to its ORIGINAL state as defined in the HTML (whatever value/checked/selected attributes were set when the page loaded), not necessarily to blank. A text input with value="New York" in its markup will revert back to 'New York' after a reset, not to an empty string, which surprises users and developers who assume 'reset' always means 'clear everything'.

Exercises

EasyPractice using Reset in a real scenario.
View Solution
<form>
  <input type="text" name="city" value="New York">
  <button type="reset">Reset</button>
</form>

Frequently Asked Questions

Does clicking a reset button always clear form fields to empty?

No — reset restores every field to its ORIGINAL state as defined in the HTML (whatever value/checked/selected attributes were set when the page loaded), not necessarily to blank. A text input with value="New York" in its markup will revert back to 'New York' after a reset, not to an empty string, which surprises users and developers who assume 'reset' always means 'clear everything'.

Related Functions

button-tagSubmit