File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Colored Text in Pull-down Menu

 
jacq carballo
Ranch Hand
Posts: 42
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hello!
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:
<select>
<option><font color="red">test1</font>
</select>
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.
tia
jacq
 
Eric Pascarello
author
Rancher
Posts: 15385
6
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You can do it with CSS....
here are the two ways
first way is to do it for the entire dropdown
<form>
<p><select size="1" name="D1" style="color: #FF0000">
<option value="A">A</option>
<option value="B">B</option>
</select></p>
</form>
Second one is to do it individually
<form>
<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>

</select></p>
</form>

Hope this helps
 
Brian Quinn
Ranch Hand
Posts: 32
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Eric,
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
author
Rancher
Posts: 15385
6
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.

Eric
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64182
83
IntelliJ IDE Java jQuery Mac Mac OS X
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Brian, please do not hijack other people's topics. You should have pursued this in the topic you opened for this issue.
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic