Change css form color from esp32 if statement
First print everything up to the colour. Then print the colour, which you change depending on the state of the pin. Then print the rest.

client.print("&lt;button style='background-color: ");

if (digitalRead(PIN) == HIGH) {
    client.print("#0CF30C");
} else {
    client.print("#F30C0C");
}

client.print("; color:#000;'&gt;&lt;/button&gt;");