DIGIT-ARC read-only archive · snapshot: July 23, 2026

Conditions in CSS

2 posts · originally from https://geek.digit.in/community/threads/conditions-in-css.109986/

RCuber
RCuber Original post #1
Mar 4, 2009 at 7:13 PM
Hi guys, I need some help in CSS.

I have a table in which the row values are something like this

------------------
|YES|NO|
|NO|NO|
|NO|YES|
----------------

I want to make the forecolor for "YES" as green and "NO" as red.

how can this be achived in CSS. if there any if else statement in CSS?
if this is difficult to achive then can CSS change the color of those text if found anywhere in whole body?
astroutkarsh
Mar 6, 2009 at 1:01 PM
well, there is no If..Else in CSS.
You can use Java script for this.
You can check "innerText" of an element (td in your case).
Then you can apply new style to this Element object like
objElement.style.backgroundColor [ = sColor ] where sColor can be "transparent" or Hex value of color.