Solved

how to change the color of a text inside select box

Posted on 2009-05-18
4
444 Views
Last Modified: 2013-11-17
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
0
Comment
Question by:whspider
  • 3
4 Comments
 
LVL 39

Expert Comment

by:abel
ID: 24411095
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
0
 

Author Comment

by:whspider
ID: 24411327
is there any way that we get the result in all cross browsers
0
 
LVL 39

Accepted Solution

by:
abel earned 500 total points
ID: 24413449
Only with extension select boxes. That means: building it yourself with using javascript and divs. Sorry, but that's the way it is and there's a lot of critique but the W3C committee so far has not changed it (in the future, yes, but not now).This is one of those cases where I have to disappoint and say "it cannot be done", really.

There are many (try google) alternatives, because many people hate this default style of the listboxes (and just so many people argue that you should not change it because people are accustomed to it). Here are two: one with checkboxes, and not the dropdown functionality, and one with a simple and clear tutorial (and only client side html + javascript what I see).
0
 
LVL 39

Expert Comment

by:abel
ID: 24419180
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.
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Hovering effect 9 46
text on slider doesn't resize nicely 5 37
Syntax Error 2 42
Remove lines by logo 2 20
Objective of This Article In 1990’s, when I was a budding software professional, I had a lot of confusion about which stream or technology, I had to choose to build my career. In those days, I had lot of confusion like whether to choose System so…
SASS allows you to treat your CSS code in a more OOP way. Let's have a look on how you can structure your code in order for it to be easily maintained and reused.
The purpose of this video is to demonstrate how to set up an RSS Feed on a WordPress Website. This will be demonstrated using a Windows 8 PC. Feedburner will be used for this demonstration. Go to your WordPress login page. This will look like the…
The viewer will receive an overview of the basics of CSS showing inline styles. In the head tags set up your style tags: (CODE) Reference the nav tag and set your properties.: (CODE) Set the reference for the UL element and styles for it to ensu…

929 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now