HTML form contains HTML form elements. HTML form elements are different types of input elements like checkboxes, text fields, submit buttons, radio buttons, etc.
The <input> Element:
The input element is used to create form fields, to take input from the user. We can use different input fields to collect information from the users.
The input element can be displayed in different ways, depending on the type attribute.
The <select> Element:
HTML <select> element is used to create a drop-down list of option. The drop-down list will appear when we click on the form element and allows the user to choose one of the options.
The <option> element is used to define the possible options to select from. The <option> tag is put inside the <select> tag. The first item in the drop-down list is selected by default, to define the pre-selected option you can add the selected attribute to the option.
The size attribute is used to specify the number of visible values of the drop-down list.
Allow Multiple Selections:
The multiple attribute is used to allow the users to select more than one value from the drop-down list.
The <textarea> Element:
The <textarea> element is used inside the form which allows the user to input the text over multiple lines.
The rows attribute specifies the number of lines in a text area.
The col attribute specifies the width of a text area.
You can use CSS to define the size of the text area.
The <button> Element:
The <button> element is used to create a clickable button within the HTML form on your webpage.
HTML5 Form Elements:
HTML5 added the following form elements:
The <datalist> Element:
The <datalist> element specifies a set of pre-defined options for an <input> element, which can be used to provide the quick choices for an input field. To bind the<datalist> element together the list attribute of the input element is used.
The <output> Element:
The HTML <output> tag is used for representing the result of a calculation.