1. Home
  2. Computing & Technology
  3. Web Design / HTML

The Select and Option Tags
HTML Forms Tutorial

By , About.com Guide

The <select> and <option> tags create drop-down menus for your forms.

<select></select>
The select tag, like the checkbox and radio button input tags allows your readers to choose from multiple options. However, because the options are all stored in a drop-down box, they do not take up as much screen real estate as the radio buttons and checkboxes.

The select tag has several attributes, and the closing </select> tag is required.

  • name - names the input information
  • size - how many items in the list are showing on the screen at once
  • multiple - the reader can choose multiple items

The tricky part of the <select> tag is that it needs a second tag to include the elements in the list: the <option> tag.

<option></option>
The option tag has two primary attributes:

  • value - if this is not included, the form will send the server whatever text is in the <option> tag as the value
  • selected - if this is not included, the form will display the first element listed as the default choice.

Here are three types of select lists:

Basic Select List

<select name=\"1\" size=\"1\">
<option>one</option>
<option>two</option>
<option>three</option>
</select>

Basic Multiple Select List

<select name=\"2\" multiple size=\"1\">
<option>one</option>
<option>two</option>
<option>three</option>
</select>

Multiple Select with Multiple Showing

<select name=\"3\" multiple size=\"2\">
<option value=\"1\">one</option>
<option value=\"1\">two</option>
<option value=\"1\">three</option>
</select>

Textarea and Select Tags in Action
Textarea, Select and Option Tag Attributes

Part 5 of the HTML Forms Tutorial: The Method Attribute of the <form> Tag
You have two options for submitting your HTML forms, and both have specific purposes.

Explore Web Design / HTML
About.com Special Features

Holiday Central

What to eat, where to go, fun things to do and how to save money on the perfect gifts. More >

Family Tech Center

Stay connected and entertained with reviews on tips on the latest HDTVs, cellphones and more. More >

  1. Home
  2. Computing & Technology
  3. Web Design / HTML
  4. HTML and XHTML
  5. XHTML
  6. Forms
  7. Select Tags and Option Tags - HTML Forms Tutorial - Using Select Tags and Option Tags>

©2009 About.com, a part of The New York Times Company.

All rights reserved.