tags:

views:

1845

answers:

4

Hi

Is it possible to have an HTML select field where the OPTION text is of different colors?

<select>
<option>Black_text (yellow_text)</option>
</select>

I tried using an CSS SPAN element to color the text but that doesn't seem to work.

Any ideas?

UPDATE: Note, I'm trying to have multiple font colors on the same OPTION row. I've seen quite a few tutorials on how to style the entire OPTION row but I'm trying to style elements within the same option row.

+4  A: 

Try to style the option elements itself:

<option style="…">Label</option>

But I doubt that browsers support much styling of these elements.


Edit

I'm trying to have multiple font colors on the same OPTION row.

That’s not possible as the option element does only allow text as content:

<!ELEMENT OPTION - O (#PCDATA)         -- selectable choice -->
Gumbo
This does work, it's quite common on things like forum posting pages, to have a dropdown with text-color choices, with the color name in the actual color. (What a terrible sentence, I hope that makes sense)
Chad Birch
Nope, doesn't work because that would style the *entire* OPTION row. Like Chad said above, what I'm trying to do is have multiple font colors on the *same* OPTION row
A: 

You might take a look at http://www.netmechanic.com/news/vol4/design_no19.htm

That looks to be styling the entire OPTION row, I'm looking to have multiple font colors on the *same* OPTION row.
+1  A: 

You probably can't do it with a plain vanilla select list. However, it probably would be possible to use Javascript + HTML + CSS to make your own "select list" using just div and span elements and that correct onclick, and onmouseover javascript. Would be much more difficult, but if it's really important, you could probably get it to work.

Kibbee
A: 

Why dont you put a background image on every row like this:

<option style="background-image: multicolorimage.jpg>some text</option>

sorry, wrong answer. At first I didnt understand what you are trying to do so disregard my post :)