Select Box Control in HTML

A select box, also called drop down box which provides option to list down various options in the form of drop down list, from where a user can select one or more options. Select box is created using the <select> element and <option> element. The option elements within the <select> element define each list item. Example :
<!DOCTYPE html>
<html>
   <head>
   <title>Select Box Controls</title>
   </head>
   <body>
     <form action="login_page.php" method="post">
     Select Yuor Faveriote Search Engine :
     <select name="searchE">
        <option value="google">Google</option>
        <option value="Yahoo">Yahoo</option>
        <option value="Bing">Bing</option>
        <option value="Sodan">Sodan</option>
        <option value="yandex">Yandex</option>
     </select>
     </form>
   </body>
</html>
The output of above code will be :


Attributes :

The attributes used in the <select> tag are as follows :

  • name : Used to give a name to the control which is sent to the server to be recognized and get the value.
  • size : This can be used to present a scrolling list box.
  • multiple : If set to "multiple" then allows a user to select multiple items from the menu.

The attributes used in the <option> tag are as follows :

  • value : The value that will be used if an option in the select box box is selected.
  • selected : Specifies that this option should be the initially selected value when the page loads.
  • label : An alternative way of labeling options.



Next Topic :