Can you use if-then in CSS/HTML?

Can you use if-then in CSS/HTML? Here’s an example code


<style>
p {
  font-size: 20px;
}

@media (max-height: 800px) {
  p {
    font-size: 10px;
  }
}
</style>

I am someone who has a background in Python, so when I see that media query uses conditional statement I immediately think somekind of If-Then function, can you use an if-then conditional statement in CSS/HTML? Or does it have to be in a format where the “if” is replaced with “@media”?

No you cannot write an if statement in plain CSS or HTML. But you can in sass which compiles to CSS.

Hi,
You can use if/else even in HTML code by using Handlebars.

Here is the link for conditionals.

Don’t Handlebars use JS ?

No, Vanilla HTML OR CSS do not allow that, but the problem can easily by solved by the other member of the Web Dev Holy Trinity, Javascript.
And there are no overhead expenses, most browsers support Javascript today natively,