File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes HTML, CSS and JavaScript and the fly likes Colored Text in Pull-down Menu Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Java Interview Guide this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Engineering » HTML, CSS and JavaScript
Bookmark "Colored Text in Pull-down Menu" Watch "Colored Text in Pull-down Menu" New topic

Colored Text in Pull-down Menu

jacq carballo
Ranch Hand

Joined: Feb 10, 2002
Posts: 42
i was wondering if there is a way to make the text in the pull-down menu colorful.
i tried using the <font color=""> tags between the text after the option tag like:
<option><font color="red">test1</font>
i've also tried to put the font tags before and after the select tags, but nothing happened.
i've tried looking for the answers in all the books i could get but no answer still. google was no help either.
would really appreciate it if someone could help.
Eric Pascarello

Joined: Nov 08, 2001
Posts: 15385
You can do it with CSS....
here are the two ways
first way is to do it for the entire dropdown
<p><select size="1" name="D1" style="color: #FF0000">
<option value="A">A</option>
<option value="B">B</option>
Second one is to do it individually
<p><select size="1" name="D1" >
<option value="A" style="color: #FF0000">A</option>
<option value="B" style="color: #00FF00">B</option>
<option value="C" style="background: #00FF00">B</option>


Hope this helps
Brian Quinn
Ranch Hand

Joined: Dec 23, 2003
Posts: 32
How do you keep the color if you select one of the options? I have a drop down with 1 red element, but when you choose it , it comes up black in the select box.
Eric Pascarello

Joined: Nov 08, 2001
Posts: 15385
As I said in your post you can not do it. It is a browser property and not anything that relates to the selection list.

Bear Bibeault
Author and ninkuma

Joined: Jan 10, 2002
Posts: 63873

Brian, please do not hijack other people's topics. You should have pursued this in the topic you opened for this issue.

[Asking smart questions] [About Bear] [Books by Bear]
I agree. Here's the link:
subject: Colored Text in Pull-down Menu
jQuery in Action, 3rd edition