Colour coded SELECT

O

Otuatail

Hi
This is probably a none starter but, What I would like is to colour code a
Select drop down with some items in green and the rest in blue. I am
trying things like

option Value="0"><style="color=#ffcc00#">Premier < /option

any Ideas.

TIA

Paul
 
O

OllimaX

option Value="0"><style="color=#ffcc00#">Premier < /option

any Ideas.

<select>
<option Value="0" style="color:#ffcc00;">Premier </option> //or
<option Value="1" style="background-color:#ffcccc;">Premier </option>
</select>

works in IE, not in Opera

Oll¡maX!
 
J

Jukka K. Korpela

OllimaX said:
<select>
<option Value="0" style="color:#ffcc00;">Premier </option> //or
<option Value="1" style="background-color:#ffcccc;">Premier </option>
</select>

It's safer to set color and background always together, since you
cannot possibly know the browser defaults. Besides, it's more logical,
and more esthetic, to use class attributes in HTML and put the specific
visual styling into a separate style sheet. E.g.,

<option value="0" class="special">Premier</option>

with a CSS file containing

option.special { color: #fc0; background: #fff; }
 
O

OllimaX

It's safer to set color and background always together, since you cannot
possibly know the browser defaults. Besides, it's more logical, and more
esthetic, to use class attributes in HTML and put the specific visual
styling into a separate style sheet. E.g.,

<option value="0" class="special">Premier</option>

with a CSS file containing

option.special { color: #fc0; background: #fff; }

HI!

Sure it is iser to useclasses, but in this case I wrote the style directly
to the element to point out the syntax.

But, Jukka, what do you actually mean by writing
'It's safer to set color and background always together, since you cannot
possibly know the browser defaults.'.
I can't quite follow you...?

Oll¡maX
 
D

David Graham

Sure it is iser to useclasses, but in this case I wrote the style directly
to the element to point out the syntax.

But, Jukka, what do you actually mean by writing
'It's safer to set color and background always together, since you cannot
possibly know the browser defaults.'.
I can't quite follow you...?

Oll¡maX

He means if you just set the color, for example to green, and did not set
the background color then you may present your page to a user who has green
as their default background color - in which case, that user will see no
text.

HTH
David
 
O

OllimaX

He means if you just set the color, for example to green, and did not set
the background color then you may present your page to a user who has
green
as their default background color - in which case, that user will see no
text.

HTH
David

That would actually be a very useful effect on many sites I have seen
around:)


Oll¡maX!
 
D

David

But, Jukka, what do you actually mean by writing
'It's safer to set color and background always together, since you cannot
possibly know the browser defaults.'.

There may be browsers that use #fc0 as the default background color
for OPTIONs. The user can also make an own stylesheet with the same
behavior.
The user won't see the content then, since the color of the text and
the background color is the same.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,430
Messages
2,571,676
Members
48,796
Latest member
Greg L.

Latest Threads

Top