An HTML form is used to collect user input. The user input is most often sent to a server for processing.
An HTML form is a section of a web page that allows users to input data, which is then sent to a server for processing.
Forms can be used for a variety of purposes, such as collecting information for surveys or registration processes, or for entering shipping or credit card data to order a product.
HTML forms are made up of a container called the HTML form element, which contains other HTML form elements, such as:
<input>, <label>, <select>, <textarea>, <button>, <fieldset>, <legend>, <datalist>, <output>, and <option>.
The HTML <form> element is used to create an HTML form for user input:
Syntax:
<form>
...
form elements
..
</form>
The <form> element is a container for different types of input elements, like: text fields, checkboxes, radio buttons, submit buttons, etc.
The HTML <input> element is the most used form element.
An <input> element can be displayed in many ways, depending on the type attribute.
Here are some examples:
Type | Description |
---|---|
<input type="text"> | Displays a single-line text input field |
<input type="button"> | Displays a clickable button |
<input type="submit"> | Displays a submit button (for submitting the form) |
<input type="radio"> | ;Displays a radio button (for selecting one of many choices) |
<input type="checkbox"> | ;Displays a checkbox (for selecting zero or more of many choices) |