Web Design Stuff
HTML Tutorials    CSS Tutorials    Web Hosting   Resources
Create a Web Page 101
Making Web Pages Intro What is a Web Page? Why Make a Web Page? The History of HTML Learn HTML or XHTML?
Basic HTML
Basic HTML Tutorials Basic HTML Necessities How to Make a Web Page How to Edit a Web Page The Basics of HTML Tags Basic HTML Page Structure HTML Attributes
HTML Font Codes
HTML Font Codes Intro HTML Font Color Codes HTML Font Size Codes HTML Font Style Codes HTML Bold/Italic Codes Combining Font Codes
Formatting Text
Formatting Text Intro Making Paragraphs Miscellaneous Formatting Headings & Subheadings Creating Hyperlinks
Using Graphics
Using Graphics on the Web Add Graphics to Your Pages Graphics and Accessibility How to Align Graphics Page Color & Background Graphics as Hyperlinks Horizontal Rules
Creating Tables
HTML Tables Tutorials HTML Table Fundamentals Background & Border Color Table Frames & Rules Table Width and Alignment Cells 1 -Space & Alignment Cells 2 -Row Column Span Cells 3 -Width & Height
Making Lists
HTML Lists Tutorials Bulleted Lists Numbered Lists Definition Lists
HTML Frames
HTML Frames Tutorials Using Frames for Layout Advanced Frame Layouts Putting Hyperlinks in Frames Frame Border Width Color, Margin and Control Problems with Frames SmartFrames: A Solution SSI: An Alternative to Frames
Web Page Forms
Making Feedback Forms A Simple Feedback Form Installing NMS FormMail Debugging Your Setup My Web Host is Out to Lunch User Input Components Text Fields Checkboxes & Radio Buttons Dropdown Menus Push Buttons Layout and Presentation
Basic CSS
Basic CSS Tutorials What is CSS? Why You Should Use CSS How to Use CSS Inline Styles Embedded Style Sheets External Style Sheets Class Selectors ID Selectors Combining Selectors
CSS Properties
CSS Properties Intro Font Styles Width, Height & Spacing Borders Backgrounds Position Float & Alignment Hyperlinks
All About Web Hosting
Hosting Your Own Website What is a Web Host? Your Website's Home Page Building a Website Offline About Free Web Hosting Best Free Web Hosting Commercial Web Hosting How to Get a Domain Name Ecommerce Web Hosting Web Hosting Terminology
Free Web Design Tools
Best Free Website Tools Best Free Text Editors Best Free Graphics Editors Free Website Analysis Tools
Setting Up HTML Kit
HTML Kit Introduction How to install HTML Kit Screenshot Breakdown Basic Configuration Overall Appearance Shortcuts and Startup Editing Window Customizing Toolbars Using the Favorites Tab Making a New Actions Bar Odds and Ends
Free Templates
Free Website Templates Two Column Fixed Width Three Column Liquid Layout Miscellaneous Templates Dynamic Menu Effects Two Column Experimental Terms of Use About These Templates
Website Templates Help
Getting Started Template Zip File Download How to Edit Your Template What to Edit in the HTML How to Add Your Logo Making a Website
Web Design Tips
Web Design Basics Tables vs. Tableless Using Tables for Layout Example Table Layouts World's Crappiest Web Page
Twitter Backgrounds
Twitter Backgrounds Intro Cool Twitter Backgrounds Cool Twitter Backgrounds 2 Plain Twitter Backgrounds Dark Twitter Backgrounds Best Twitter Backgrounds Cute Twitter Backgrounds Music Twitter Backgrounds Music Twitter Backgrounds 2 Twitter Backgrounds 101 TERMS OF USE
All About Web Browsers
What is a Web Browser? Mozilla Firefox Internet Explorer Opera How to Set Up Firefox Top 5 Firefox Extensions
 
Contact
Post Some Feedback Send Me An Email Iron Spider Blog About Iron Spider... Site Conventions
 
 
 

 

Dropdown Menus

 
ON THIS PAGE
  • A Simple Dropdown Menu
  • How Dropdowns Work
  • Setting Default Selection
  • Allow Multiple Selections
  • How Many Rows to Display
  • Making Menu Subsections
  • Advanced Dropdown Menu
 
You can prompt users for input by offering them a list of items displayed in a dropdown menu. The user clicks on the down arrow to open a list that 'drops down' and then clicks on a menu item in the list to select it. The items in the menu list are, by default, configured to be mutually exclusive of one another (like radio buttons) but can also be set to support multiple selections (like checkboxes). Dropdown menus offer the distinct advantage of being great space savers (they also look cool).

Dropdown menus are created by using the select element which acts as a container for a group of menu items, each of which is created by using the option element. Both the select element and the option element have start and end tags, e.g. <select>...</select> and <option>...</option>.


A SIMPLE DROPDOWN MENU

Here's a dropdown menu prompting the user to specify how they like their coffee:

I like my coffee:


SOURCE CODE

I like my coffee:<br><br>

<select name="coffee">

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

<option value="cream" selected>With cream</option>

<option value="sugar">With sugar</option>

<option value="regular">With cream & sugar</option>

<option value="crisp">Crisp (har har...)</option>

</select>


^ Top ^


HOW DROPDOWN MENUS WORK

A group of menu items is created —each using the option element— and then placed within a containing select element. The start <select> tag contains the control name for the menu item group. In the above example, the control name is "coffee". Each menu item in the group has a different associated value specified by the value attribute. When a user selects a menu item, its value gets assigned as the current value of the menu item group's control name.

^ Top ^


DEFAULT SELECTION

Web browsers will typically display the first menu item in the list as the default selection (the one that first appears in the menu window in its closed state). You can, however, specify which menu item this is by inserting the selected attribute. In the above example, the menu item "With cream" is set as the default selection.

^ Top ^


MULTIPLE SELECTIONS

You can set the dropdown menu to permit the user to make multiple selections by inserting the multiple attribute in the <select> start tag. To see this in effect, please refer to the example below.

^ Top ^


HOW MANY ROWS TO DISPLAY

The default closed state of a dropdown menu displays just a single line but you can set this to as many lines as you wish. This is accomplished by using the size="nn" attribute-value pair in the <select> start tag where nn equals the number of lines you wish to display. With the menu configured to multiple lines, it loses its 'dropdown' style and becomes a scrollable list of menu items. To see this in effect, please refer to the example below.

^ Top ^


MAKING MENU SUBSECTIONS

An extensive list of menu items may serve the user better if it was organized into subsections. Each subsection is then given a title that describes the group of menu items it contains. This is accomplished by placing all the menu items you wish to define as a subsection between a set of <optgroup>...</optgroup> tags. The label="section_name" attribute-value pair is inserted in the <optgroup> start tag where section_name equals the title of the subsection.To see this in effect, please refer to the example below.

^ Top ^


AN ADVANCED DROPDOWN MENU

In the following example, the menu employs subsections, displays five rows at a time and permits the user to make multiple selections. The menu item "Cream" is selected by default. The user makes multiple selections by pressing Ctrl on his keyboard while clicking on each menu item. (Menu items are 'deselected' in the same manner).

I like my coffee with:


SOURCE CODE

<select name="coffee2" size="5" multiple>

<optgroup label="Dairy">
<option value="skim">Skim Milk</option>
<option value="milk2">Milk (2%)</option>
<option value="cream" selected>Cream</option>
<option value="whipped">Whipped cream</option>
</optgroup>

<optgroup label="Sweetener">
<option value="sugar">Sugar</option>
<option value="honey">Honey</option>
</optgroup>

<optgroup label="Snack">
<option value="donut">A donut</option>
<option value="danish">A danish</option>
<option value="muffin">A muffin</option>
</optgroup>

</select>




Alright then, let's move on to creating the push buttons that will activate your web form...





Best Free Stuff
for webmasters

Free Text Editors
Free Graphics Editors
Website Analysis Tools
Free Website Templates

See also:

Best Free Web Hosting

 

If you need a .COM web address, you can get one quick and easy at...

www.GoDaddy.com
<~ BACK TOP NEXT ~>
 
HTML Tutorials |  CSS Tutorials |  Web Hosting |  Domain Names |  Web Design Resources
Iron Spider © Copyright 2004-2011 Robert Darrell