HTML Form Elements
All of the HTML elements are described in this chapter.
One or more of the form elements in the HTML < form >
can include:
input
select
label
textarea
button
fieldset
legend
dataset
output
option
optgroup
The <label> Element
The element label
defines a label text for a number of form elements.
For screen-reader users, the label
element is useful because when a user concentrates on the input element,
the screen-reader reads out label
loudly.
Note: The label
tag's attribute must be equal to the input
element id attribute for
binding together.
The <input> Element
The input
element is one of the most frequently used form elements.
Depending on the type
attribute, the input
element can be shown in several different ways.
Example:-
Output :-
If you click "Submit", the form-data will be sent to a page called "submit.aspx".
Tip: When you change the input values and then click the "Reset" button, the form-data is reset to its default values.
The following chapter covers all the different values of the type attribute: HTML Input Types.
Related Links
The <select> Element
The select
element defines a drop-down list or multi choice list box.
The option
element is used to add an item to the drop down list. The element of the option
specify an option to select.
Add the selected
attribute to the option
element to define the preselected option.
Default is to select the first item from the drop-down list.
The size
attribute is used to specify the number of visible values and make the dropdown list into a listbox.
The multiple
attribute is used to choose more than one value from the list.
Tip: Hold down the Ctrl (windows) / Command (Mac) button to select multiple options.
Example:-
The select Element
The select element defines a drop-down list:
Output :-
The <textarea> Element
The textarea
element defines a multi-line input text field.
The attribute rows
indicates how many lines are visible in the text field.
The attribute cols
characteristics specify the visible width of a field.
Example 1:-
Output :-
Related Links
The <datalist> Element
The element datalist
is used to lists the preset options to an element input
. When you enter data, users will
view a list of the predefined options.
The input
element's attribute for list must refer to the datalist
element's id attribute.
Example :-
Output :-
Tip: You can select a pre-defined options or enter a new one.