navigation
Thomas Brunt's OutFront Hosting
 
Sponsors

Shopping Cart Software
Ecommerce software integrated into Frontpage, Dreamweaver and Golive templates. No monthly fees and available in ASP and PHP versions.

Website Templates
We also have a wide selection of Dreamweaver, Expression Web and Frontpage templates as well as webmaster tools and CSS layouts.

Frontpage website templates
Creative Website Templates for FrontPage, Dreamweaver, Flash, SwishMax

 

Creating Funky Forms with CSS  Part V  
by Outfront Moderator Katherine Nolan (abbeyvet)

Styling Dropdown Lists

Adding styles to a drop down list can not only make it look interesting, it can add to usability also. 

In this example I am going to look at adding style to a drop down list in a typical Quick Jump menu. This is a JavaScript form, as distinct from a FrontPage one, and you can get the HTML for it here: http://www.outfront.net/tutorials_02/faq.htm#DropDown However the same principles apply to any drop down list.

I have altered the basic form to point to various pages in the OutFront tutorials section, categorized under several headings. 

If you look at that list there is a lot there and, although the lines and indentations help, not all of it is that easily seen. If all the tutorials were listed it would be even less clear. We can fix that by adding some style. 

If you look at the source of the page you will see that each item in the drop down list starts with the tag <option>, thus 'option' will be our selector, the thing to which we will add style.

There are two types of pages in this list - the category main pages and the individual tutorial pages. As it is now there is little to differentiate them visually, though the individual page names have been indented and had a '-' placed in front of them. What we can do with CSS is add two different classes for 'option' and then call them to the different options on our list.

We will stick I think to red and pink here and forget our aberration with the violet text box! 

We can create the option styles quickly by copying the styles 'red' and 'pink' we have already created for the selector 'input' and applying them to two new classes of 'option'

Thus this will be added to our style sheet.

option.red {background-color: #cc0000; font-weight: bold; font-size: 12px; color: white;}
option.pink {background-color: #ffcccc;}

So that it now reads:

<style tyle=text/css>
input.red {background-color: #cc0000; font-weight: bold; font-size: 12px; color: white;}
input.pink {background-color: #ffcccc;}
textarea.violet {background-color: #ccccff; font-size: 10px;}
option.red {background-color: #cc0000; font-weight: bold; font-size: 12px; color: white;}
option.pink {background-color: #ffcccc;}
</style>

Applying this style is a little laborious, basically you must go though the option list in HTML and add the class 'red' to all the category options and the class 'pink' to all the tutorial page options.

So that this, for example:

<option value= "../getting_started/">Getting Started </option>
<option value= "
../getting_started/html_intro1.htm">- Intro to HTML</option>

Becomes this:

<option class="red" value= "../getting_started/">Getting Started </option>
<option class="pink" value=
"../getting_started/html_intro1.htm">- Intro to HTML</option>

This is the result:

It is now a lot clearer what the options are when the list is opened.

Browser Note: This will not work in Netscape 4x, so do not abandon the text methods of laying out the list completely, combine the two.

While it is tempting to use these techniques to make very colorful forms, do try to keep things simple and clear for users. In some cases, as we have shown, using styles can make things even better and easier for users and that should always be your aim.

<< Part IV: Fun with Radio Buttons and Checkboxes

 

Fun With Background Images
Fun With Bulleted Lists
Are You Compliant?
Introduction To Cascading Style Sheets
Creating Custom Error Pages
Designing Fast Loading Sites
Creating Funky Forms With CSS
htaccess Magic
An Introduction To JavaScript
JavaScript Snippets
Getting More From Mailto
Installing And Using Perl Scripts
Preparing Photos For Your Web Site
The Popup Dilemma
Paint Shop Pro Album 4
Creating And Using robots.txt File
Creating JavaScript Rollover Buttons

Microsoft Corporation in no way endorses or is affiliated with "OutFront." 
OutFront is published and edited by Thomas Brunt
440 Great Circle Dr., St. Matthews, SC 29135.  803-655-6151
© 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006 All Rights Reserved
Click here to view our privacy statement.