?
Solved

how to change the color of a text inside select box

Posted on 2009-05-18
4
Medium Priority
?
473 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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 2000 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

Video: Liquid Web Managed WordPress Comparisons

If you run run a WordPress, you understand the potential headaches you may face when updating your plugins and themes. Do you choose to update on the fly and risk taking down your site; or do you set up a staging, keep it in sync with your live site and use that to test updates?

Question has a verified solution.

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

Styling your websites can become very complex. Here I'll show how SASS can help you better organize, maintain and reuse your CSS code.
This article discusses four methods for overlaying images in a container on a web page
The purpose of this video is to demonstrate how to automatically show related posts at the bottom of a blog post in WordPress. This will be demonstrated using a Windows 8 PC. Plugin “Yet Another Related Posts Plugin” will be used. Go to your…
The purpose of this video is to demonstrate how to properly insert a Vimeo Video into a WordPress site or Blog. This will be demonstrated using a Windows 8 PC. Go to your WordPress login page. This will look like the following: mywebsite.com/wp…
Suggested Courses

777 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