Link to home
Start Free TrialLog in
Avatar of whspider
whspider

asked on

how to change the color of a text inside select box

Hi,

i have the following code

<select size="1" name="C1" >
 <option>no=1</option>
  <option>no=2</option>
  <option>no=3</option>
  <option>no=4</option>

how do i change the color of "no=" alone to some other color...to differentiate from number
Avatar of abel
abel
Flag of Netherlands image

The best you can do in standard HTML and CSS is use the pseudo element :first-letter. Unfortunately, the designers of CSS never thought of :first-word. And it is not possible to use a <span> inside a listbox. However, there are many custom made listboxes around that basically mimic the listbox behavior using <div> tags.

Here's what I meant (and by using the Numero sign, the first two in the list, you can get the suggestion of two letter having a different color, but it is not pretty and it does not work on IE7):

option:first-letter {
    color: red;
}

Open in new window

ScreenShot289.png
Avatar of whspider
whspider

ASKER

is there any way that we get the result in all cross browsers
ASKER CERTIFIED SOLUTION
Avatar of abel
abel
Flag of Netherlands image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
I didn't give that link about "it cannot be done" for nothing. We love to help, but sometimes we must say that it cannot be done. The result is: a low grade. That's not the idea and that takes away our pleasure in doing so or answering questions like that. Please read that help article and read the 10pts must principle.