Cascading Style Sheets (CSS)

Style Select and Option Elements

Give drop down list and other option elements a style that fit your page layout.

First style the select element. In this example we have given font size 16px and font weight bold.

Then style the option element. We use two styles here, one for regular and one for odd rows. See the class element in the select list. You can easy style each select element.

The CCS code:
select {
    font-size:16px;
    font-weight: bold;
}
option {
    color: white;
    background-color: #0066ff;
}
option.odd {
    color: yellow;
    background-color:#0033cc;
}
    

The drop down list code:
<form method="post"action="next_page.cfm">
  <select size="1"name="fovorite_pet">
    <option>Select your favorite pet:</option>
    <option value="Pig">Pig</option>
    <option value="Bird" class="odd">Bird</option>
    <option value="Fish">Fish</option>
    <option value="Cat" class="odd">Cat</option>
    <option value="Dog">Dog</option>
    <option value="Rabbit" class="odd">Rabbit</option>
  </select>
  <input name="Submit" type="submit"value="Favorite Pet" />
</form>

This will give a drop down list like this:
 

CSS Stle drop down list

No User Comments.

No User Comments, be the first one to write your comments?

Add your comments

Your Name*:
Your Email:
Site URL:
Site Name:
Comemt Title*:
Your Comment*:
Key Phrase*:
zJ9
Your IP Address: 38.103.63.62
 

ScandicWeb is own by Scandic Systems LTD [UK] Company No. 5984000. All other trademarks and copyrights are the property of their respective holders.

[Home [Site Map [Privacy Statement [Site Feedback] [About ScandicWeb]


[ColdFusion [Flash [Search Engine Optimization [Graphics [Cascading Style Sheets (CSS) [JavaScript (JS) [Software]

Partner sites: ScandicSoft


Server time: 19. November 2008 Wednesday