HTML · HTML Forms · Lesson 40
HTML Forms
Collect user input with forms and input fields.
An HTML form is used to collect user input. The input is most often sent to a server for processing.
Example
<form action="/submit">
<label for="fname">First name:</label><br>
<input type="text" id="fname" name="fname"><br>
<label for="lname">Last name:</label><br>
<input type="text" id="lname" name="lname"><br><br>
<input type="submit" value="Submit">
</form>
The input Element
| Type | Description |
|---|---|
| <input type="text"> | A single-line text field |
| <input type="password"> | A password field (characters are masked) |
| <input type="radio"> | A radio button — select ONE of many |
| <input type="checkbox"> | A checkbox — select ZERO or MORE |
| <input type="submit"> | A button that submits the form |
Keep reading “HTML Forms”
Sign up to read the full lesson (3 more parts), try every example in the live editor, and take the 5-question quiz.