Form controls are the interactive elements inside a form that allow users to enter or select information. They appear inside:
<form> ... </form>
The most commonly used form control. Types of <input>
<input type="text"> <!-- Single-line text -->
<input type="password"> <!-- Hidden characters -->
<input type="email"> <!-- Validates email -->
<input type="number"> <!-- Accepts numbers -->
<input type="date"> <!-- Calendar date picker -->
<input type="file"> <!-- Upload files -->
<input type="checkbox"> <!-- Multiple selection -->
<input type="radio"> <!-- Single selection in group -->
<input type="submit"> <!-- Submit button -->
<input type="reset"> <!-- Reset form -->
<input type="button"> <!-- Normal button -->
Used for multi-line text input (e.g., descriptions, comments).
<textarea rows="4" cols="50"></textarea>
Dropdown menu.
<select>
<option value="india">India</option>
<option value="usa">USA</option>
<option value="uk">UK</option>
</select>
More flexible than input buttons.
<button type="submit">Submit</button>
<button type="reset">Reset</button>
<button type="button">Click Me</button>
Describes an input field — improves accessibility.
Clicking the label focuses the input.
<label for="email">Email:</label>
<input type="email" id="email">
Groups related form elements.
<fieldset>
<legend>Personal Info</legend>
<input type="text" placeholder="Name">
<input type="email" placeholder="Email">
</fieldset>
Provides suggestions while typing.
<input list="countries">
<datalist id="countries">
<option value="India">
<option value="USA">
<option value="Japan">
</datalist>
Displays calculation results.
<form oninput="result.value = a.value * b.value">
<input type="number" id="a"> ×
<input type="number" id="b">
= <output name="result"></output>
</form>
Shows progress bar.
<progress value="50" max="100"></progress>
Represents a known range value (e.g., rating).
<meter value="6" min="0" max="10"></meter>
| Form Control | Purpose |
|---|---|
| <input> | Various single-line inputs |
| <textarea> | Multi-line text |
| <select> | Dropdown list |
| <option> | Options inside dropdown |
| <button> | Clickable button |
| <label> | Describes input |
| <fieldset> | Group inputs |
| <legend> | Title of fieldset |
| <datalist> | Suggestion list |
| <output> | Calculation output |
| <progress> | Progress bar |
| <meter> | Range indicator |