webdevlinux - logo Web Dev Linux

Select & options

Select options are used to select one or more options from a list. In this chapter, you will learn the different ways to use select options in an HTML form.

Select options HTML select options

Try the example below.

FILE : select.html
<!DOCTYPE html>
<meta charset="utf-8" />
<p>Select your birthday : 
<p>Select your gender : 
	<select size="2">
		<option selected>Male</option>	
<p>Social networks you use :
	<select multiple>
		<option>Linked In</option>	


Take a look at the explanation of elements & attributes used in the example.

The select element represents a selectable set of options.
The option element represents a single option of the set.
The selected attribute represents the default selected value of the set.
The size attribute represents the number of options to display. Default size value is 1 on select elements when the multiple attribute is not specified.
With the multiple attribute, it is possible to select multiple options. Use the control key to select more options. When this is specified the default display size of the element is 4.