How do you change background color on td in CSS?

I am trying to change background color on table cell depending on tp1_value.
tp1_value is selected cell value from database table and it is either True or False.

How do I make this so background-color become ‘green’ on true, ‘red’ on false? Default color is grey before I click table cell which is null value.

It doesn’t seem like I can use if statement on css. ­čÖü

    <table class="t1">

            <tr>
                <td id="tp1"><div class="t"><label id="tp1_value"></label></div></td>
            </tr>
    </table>

#tp1_value {
        background-color: grey;
}

48 thoughts on “How do you change background color on td in CSS?”

  1. I know this if off topic but I’m looking into starting my own weblog and was wondering what all is needed to get
    set up? I’m assuming having a blog like yours would cost a pretty
    penny? I’m not very web savvy so I’m not 100% sure.
    Any recommendations or advice would be greatly appreciated.

    Cheers

    Reply
  2. Global Ger├žek ─░nstagram Takip├ži Sat─▒n Al
    Hem ger├žek hem de kal─▒c─▒ sosyal medya takip├žisine ula┼čmak olduk├ža zordur.

    Bu say─▒ 10 bin oldu─čunda ├žok daha zordur.

    Takip2018 uzman ekip ├╝yeleri taraf─▒ndan sa─članan ger├žek ve kal─▒c─▒
    takip├žiler ile sosyal medya hesab─▒n─▒z k─▒sa s├╝rede Ke┼čfet
    sayfas─▒nda yerini alabilir.
    Siz de ─░nstagram takip├ži sat─▒n al kategorisinde yer alan 10 bin yurt i├ži ve yurt d─▒┼č─▒ takip├žinin yer ald─▒─č─▒ paketimizi tercih edebilirsiniz.

    Di─čer t├╝m paketleri g├Ârebilmek ad─▒na instagram takip├ži sat─▒n al linkimiz ; instagram takip├ži sat─▒n al

    Reply
  3. 286870 45732This constantly amazes me exactly how blog owners for example yourself can uncover the time and also the commitment to maintain on composing amazing weblog posts. Your site isexcellent and 1 of my own ought to read blogs. I simply want to thank you. 592271

    Reply