The HTML <form> element can contain one or more of the following form elements:
One of the most used form elements is the <input> element.
The <input> element can be displayed in several ways, depending on the type attribute.
Example :
<label for="fname">First name:</label>
<input type="text" id="fname" name="fname">
The <label> element defines a label for several form elements.
The <label> element is useful for screen-reader users, because the screen-reader will read out loud the label when the user focus on the input element.
The <label> element also help users who have difficulty clicking on very small regions (such as radio buttons or checkboxes) - because when the user clicks the text within the <label> element, it toggles the radio button/checkbox.
The for attribute of the <label> tag should be equal to the id attribute of the <label> element to bind them together.
Example :
<label for="cars">Choose a car:</label>
<select id="cars" name="cars">
<option value="volvo">Volvo</option>
<option value="saab">Saab</option>
<option value="fiat">Fiat</option>
<option value="audi">Audi</option>
</select>
The <option> element defines an option that can be selected.
By default, the first item in the drop-down list is selected.
To define a pre-selected option, add the selected attribute to the option:
Example :
<option value="fiat" selected>Fiat</option>