Re: CSS color conditional on content

Re: CSS color conditional on content

am 23.11.2007 10:12:29 von jkorpela

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/