Colour coded SELECT

Discussion in 'HTML' started by Otuatail, Dec 18, 2003.

  1. Otuatail

    Otuatail Guest

    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
    Otuatail, Dec 18, 2003
    #1
    1. Advertising

  2. Otuatail

    OllimaX Guest


    > 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!
    OllimaX, Dec 18, 2003
    #2
    1. Advertising

  3. OllimaX <> wrote:

    > <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; }

    --
    Yucca, http://www.cs.tut.fi/~jkorpela/
    Pages about Web authoring: http://www.cs.tut.fi/~jkorpela/www.html
    Jukka K. Korpela, Dec 18, 2003
    #3
  4. Otuatail

    OllimaX Guest

    Jukka K. Korpela <> kirjoitti Thu, 18 Dec 2003 19:41:36
    +0000 (UTC):

    > OllimaX <> wrote:
    >
    >> <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; }
    >


    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
    OllimaX, Dec 19, 2003
    #4
  5. Otuatail

    David Graham Guest


    > 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
    David Graham, Dec 19, 2003
    #5
  6. Otuatail

    OllimaX Guest

    David Graham <> kirjoitti Fri, 19 Dec 2003
    09:16:06 -0000:

    >
    >> 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
    >
    >
    >


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


    Oll¡maX!
    OllimaX, Dec 19, 2003
    #6
  7. Otuatail

    David Guest

    > 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.

    --
    David Håsäther
    David, Dec 19, 2003
    #7
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Luis Esteban Valencia
    Replies:
    1
    Views:
    516
    Curt_C [MVP]
    Jan 6, 2005
  2. kelvSYC
    Replies:
    2
    Views:
    4,679
    Brad BARCLAY
    Dec 30, 2003
  3. =?Utf-8?B?c3N0cmlk?=

    Google Map - generate colour coded areas

    =?Utf-8?B?c3N0cmlk?=, May 1, 2007, in forum: ASP .Net
    Replies:
    0
    Views:
    328
    =?Utf-8?B?c3N0cmlk?=
    May 1, 2007
  4. palmiere
    Replies:
    1
    Views:
    386
    Erwin Moller
    Feb 9, 2004
  5. jodleren
    Replies:
    2
    Views:
    188
    Thomas 'PointedEars' Lahn
    Jan 12, 2008
Loading...

Share This Page