With the dropdown list, you can create a list for the user from which the user can select any one. You are asked to create a form and select one of the favorite colors here (in many colors). If you have an option, then you can do it easily with the dropdown list.

To create a dropdown list, first start the code with <select> tags, then the items from which the user chooses to be put in the <option> tag.

<select name="color">
<option  value="bl">Black</option>
<option value="wh">White</option>
<option selected="selected" value="mr">Maroon</option>
</select>

See the example above for the selected attribute, the first option is Maroon. If you want to see White first then use the selected attribute on line 3.

Each <option> tag has a value attribute, it is very important to send the form data to the server. Call the value attribute name (eg bl, mr ..).

<select> Tag’s attribute of the attribute

With the size attribute in the <select> tag, you can set how many items will appear in the list, as if the size above the example size=2 gives two options, the rest will be scrolled.

<select name="color" size=2>

<option value="bl">Black</option>

<option value="wh">White</option>

<option selected="selected" value="mr">Maroon</option>

</select>

Multiple attributes of the <select> tag

With multiple, you can give more than one option to choose from.

<select multiple="yes">

<option value="bl">Black</option>

<option value="wh">White</option>

<option selected="selected" value="mr">Maroon</option>

</select>

* If the selected attribute is removed on line 7, then no option will be displayed and selected.

If your options list is too large, then you can group it. <optgroup> Such as

<select name="selInformation" >
<optgroup label="Tutorials" >
<option value="html"> HTML Tutorial </option>
<option value="css"> CSS Tutorials </option>
<option value="javascript"> JavaScript </option>
</optgroup>
<optgroup label="PHP Tutorials" >
<option value="basicphp"> Basic PHP </option>
<option value="advancedphp"> Advanced PHP </option>
</optgroup >
<optgroup label="Database Tutorials">
<option value="sql"> SQL Tutorial </option>
<option value="phpdatabase"> PHP Database </option>
</optgroup>
</select>