CSS color conditional on content

Discussion in 'HTML' started by Summercool, Nov 23, 2007.

  1. Summercool

    Summercool Guest

    for CSS, is it possible to say, if the content in the div or span is
    0, show the "0" in red, and if it is a "1", show it in green? I can
    use PHP or any script to do it, but it probably is quite handy to let
    CSS handle the formatting style without needing server support.
     
    Summercool, Nov 23, 2007
    #1
    1. Advertising

  2. Scripsit Summercool:

    > for CSS, is it possible to say, if the content in the div or span is
    > 0, show the "0" in red, and if it is a "1", show it in green?


    Of course not. Read a primer on CSS to get an idea of what CSS is about,
    and you won't ask questions like that.

    > I can
    > use PHP or any script to do it, but it probably is quite handy to let
    > CSS handle the formatting style without needing server support.


    There's nothing handy about it: it's not possible, and it's not
    something that CSS is meant for.

    You can use a class attribute to distinguish, say, the elements you
    would like to appear in red from those you'd like to be green. However,
    you should bear in mind that about 10% of male population are unable to
    distinguish red from green well (or at all), so even as auxiliary method
    (to highlight a difference that already exists in content, like "0" from
    "1"), it's not a good choice.

    We heard you the first time, and you crossposted pointlessly, since
    c.i.w.a.h. is strictly about HTML, not CSS (and not about server-side
    technologies either). Followups trimmed.

    --
    Jukka K. Korpela ("Yucca")
    http://www.cs.tut.fi/~jkorpela/
     
    Jukka K. Korpela, Nov 23, 2007
    #2
    1. Advertising

  3. Summercool wrote:
    > for CSS, is it possible to say, if the content in the div or span is
    > 0, show the "0" in red, and if it is a "1", show it in green? I can
    > use PHP or any script to do it, but it probably is quite handy to let
    > CSS handle the formatting style without needing server support.
    >

    The answer's still "No".
     
    Harlan Messinger, Nov 23, 2007
    #3
  4. Summercool

    the DtTvB Guest

    Harlan Messinger wrote:
    > Summercool wrote:
    >> for CSS, is it possible to say, if the content in the div or span is
    >> 0, show the "0" in red, and if it is a "1", show it in green? I can
    >> use PHP or any script to do it, but it probably is quite handy to let
    >> CSS handle the formatting style without needing server support.
    >>

    > The answer's still "No".


    However, you can use JavaScript to do it.
     
    the DtTvB, Nov 23, 2007
    #4
    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. moondaddy
    Replies:
    3
    Views:
    38,770
    moondaddy
    Apr 28, 2004
  2. PJ6
    Replies:
    4
    Views:
    4,916
  3. Alec S.
    Replies:
    10
    Views:
    10,268
    Alec S.
    Apr 16, 2005
  4. hazz
    Replies:
    6
    Views:
    49,940
    SkyUCHC
    Jun 9, 2010
  5. Kamaljeet Saini
    Replies:
    0
    Views:
    466
    Kamaljeet Saini
    Feb 13, 2009
Loading...

Share This Page