Win a copy of Java 9 Modularity: Patterns and Practices for Developing Maintainable Applications this week in the Java 9 forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Colored Text in Pull-down Menu  RSS feed

 
jacq carballo
Ranch Hand
Posts: 42
  • 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
  • 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
  • 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
  • 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
Posts: 66252
151
IntelliJ IDE Java jQuery Mac Mac OS X
  • 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.
 
Don't get me started about those stupid light bulbs.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!