Conditions in CSS

Status
Not open for further replies.

RCuber

The Mighty Unkel!!!
Staff member
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

Canon EOS 600D / 1000D
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.
 
Status
Not open for further replies.
Top Bottom