HTML Form Elements
- Previous Page HTML Form Attributes
- Next Page HTML Input Types
This chapter describes all HTML form elements.
The <input> element
The most important form element is <input> elements.
The <input> element according to different type Properties can change to various forms.
Note:The next chapter explains all HTML input types.
The <select> element (drop-down list)
<select> The element definesDrop-down list:
Example
<select name="cars"> <option value="volvo">Volvo</option> <option value="saab">Saab</option> <option value="fiat">Fiat</option> <option value="audi">Audi</option> </select>
<option> The element defines the options to be selected.
Lists usually display the first option as the selected option.
You can define predefined options by adding the selected attribute.
Example
<option value="fiat" selected>Fiat</option>
The <textarea> element
<textarea> The element defines a multi-line input field (Text area):
Example
<textarea name="message" rows="10" cols="30"> The cat was playing in the garden. </textarea>
The above HTML code is displayed in the browser as:
The cat was playing in the garden.
<button> Element
<button> element defines clickableButton:
Example
<button type="button" onclick="alert('Hello World!')">Click Me!</button>
The above HTML code is displayed in the browser as:
HTML5 Form Elements
HTML5 adds the following form elements:
- <datalist>
- <keygen>
- <output>
Note:By default, browsers do not display unknown elements. New elements will not break your page.
HTML5 <datalist> Element
<datalist> element specifies a predefined option list for the <input> element.
The user will see a dropdown list of predefined options when they enter data.
of the <input> element list The property must reference the <datalist> element's id Properties.
Example
Set predefined values for the <input> element using <datalist>:
<form action="action_page.php"> <input list="browsers"> <datalist id="browsers"> <option value="Internet Explorer"> <option value="Firefox"> <option value="Chrome"> <option value="Opera"> <option value="Safari"> </datalist> </form>
- Previous Page HTML Form Attributes
- Next Page HTML Input Types