descriptive text

Innovation im Web: Conditional CSS with if()!

As a content creator, SEO and frontend expert, I’m excited about a new features currently being tested in the Chrome Origin Trial:

👉 What is if() in CSS?

The new if() function allows you to apply styles conditionally, just like in programming languages. Depending on the media query or condition, an element automatically gets the appropriate property—no more deeply nested media queries!

As a frontend developer, this is a real relief: clearer code, less redundancy, and more maintainable, smarter responsive designs.

Practical example:

button {
  aspect-ratio: 1;
  width: if(media(any-pointer: fine): 30px; else: 44px);
}

Here, the button width is set dynamically based on the input device:


Read more in the Chrome Developer Blog

Zurück zu den Artikel