Set a background color for options in combo box

HTML, CSS and anything else that deals with client side capabilities.

Moderator: General Moderators

Post Reply
MicroBoy
Forum Contributor
Posts: 112
Joined: Sat Mar 14, 2009 5:16 pm

Set a background color for options in combo box

Post by MicroBoy »

I have a combobox, how to set a background color for a specified option. For example the option red to have Red background color etc.... I have searched a lot in google, but I didn't have any good results.
User avatar
akuji36
Forum Contributor
Posts: 190
Joined: Tue Oct 14, 2008 9:53 am
Location: Hartford, Connecticut

Re: Set a background color for options in combo box

Post by akuji36 »

It sounds like you may need css.

Do you want to see the desired colored change

when a selection is made from a list of options

in your combo box?
maneetpuri
Forum Commoner
Posts: 60
Joined: Tue Oct 07, 2008 6:32 am

Re: Set a background color for options in combo box

Post by maneetpuri »

HI,

Just define the background color in Option tag.

<select name="">
<option>Select Color</option>
<option style="background-color:red; color:#FFF">RED</option>
<option style="background-color:green; color:#FFF">GREEN</option>
<option style="background-color:black; color:#FFF">BLACK</option>
</select>

Hope This Helps,
Cheers
User avatar
pickle
Briney Mod
Posts: 6445
Joined: Mon Jan 19, 2004 6:11 pm
Location: 53.01N x 112.48W
Contact:

Re: Set a background color for options in combo box

Post by pickle »

Ya, you have to use CSS. The last I checked though, this doesn't work in Firefox.
Real programmers don't comment their code. If it was hard to write, it should be hard to understand.
MicroBoy
Forum Contributor
Posts: 112
Joined: Sat Mar 14, 2009 5:16 pm

Re: Set a background color for options in combo box

Post by MicroBoy »

thnx maneetpuri, this Worked for me :D
Post Reply