CSS color conditional on content

S

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

Jukka K. Korpela

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

Harlan Messinger

Summercool said:
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".
 

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
473,744
Messages
2,569,484
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top