HTML forms are used to collect different types of user input.
The HTML form represents an area in the document that contains interactive controls that send the information collected by the user to the Web server. A form is an area that contains form elements. Form elements allow users to enter content in the form, such as text fields (textarea), drop-down lists, radio-buttons boxes, checkboxes, and so on. Forms use form tags In most cases, the form tag used is the input tag (< input >). The input type is defined by the type type. Most of the frequently used input types are as follows: The text field is set by the < input type= “text” > tag, which is used when users type letters, numbers, and so on into the form. The browser displays as follows: First name: Last name: Note: the form itself is not visible. Also, in most browsers, the default width of the text field is 20 characters. The password field is defined by the label < input type= “password” >: The browser displays as follows: Password: Note: password field characters are not displayed in clear text, but are replaced by asterisks or dots. < input type= “checkbox” > defines a check box. The user needs to select one or more options from several given selections. The browser displays as follows: I have a bike I have a car New: new HTML5 tag Label Description < form > Define a form for user input < input > Define input field < textarea > Define a text field (a multiline input control) < label > Defines the tag of the < input > element, which is usually the input title < fieldset > Defines a set of related form elements and contains them using a bounding box < legend > Defines the title of the < fieldset > element < select > Defines a list of drop-down options < optgroup > Define option groups < option > Define options in the drop-down list < button > Define a click button < datalist > New Specify a predefined list of input control options < keygen > New Defines the key pair generator field for the form < output > New Define a calculation result 11.18.1. HTML form ¶
<form>
to set up:Example ¶
<form>
.
*input element*
.
</form>
11.18.2. HTML form-input element ¶
11.18.3. Text field ¶
<form>
First name: <input type="text" name="firstname"><br>
Last name: <input type="text" name="lastname">
</form>
11.18.4. Password field ¶
<form>
Password: <input type="password" name="pwd">
</form>
11.18.6. Check box ¶
<form>
<input type="checkbox" name="vehicle" value="Bike">I have a bike<br>
<input type="checkbox" name="vehicle" value="Car">I have a car
</form>
11.18.8. HTML form label ¶