Select Tag
Question
Explain in detail the function of the select
tag and how it is added to web pages.
Define:
The select
tag is used to make a drop down menu. This menu is commonly used in forms to select your state for example. This tag will display an empty drop down menu but requires the option tags in-between to get the desired effect. Now let’s take a look into the syntax.
Syntax
This is the syntax for the select tag. Not much to look at but this would create a dropdown menu with the listed values.
<select>
<option value ="dog">Dog</option>
<option value ="cat">Cat</option>
</select>
Example
Here is a live demonstration of the select tag. Notice the cat option has the selected
attribute. This sets the cat to be selected first if not the dog would be selected.
See the Pen ozNJQN by oscar (@nopity) on CodePen.
Browser Support
Browser | Chrome | Firefox | Explorer | Safari | Opera |
---|---|---|---|---|---|
Support | yes | yes | yes | yes | yes |