<if>

An experimental function that allows you to apply different values based on a condition (like a media query or a variable state) directly within a property value.

This is an experimental technology. The syntax and behavior are still subject to change.

/* Usage Example */
button {
  /* Experimental: change padding based on a wide screen variable */
  padding: if(var(--is-wide): 1rem 2rem; else: 0.5rem 1rem);
}

This comparison shows how <if> works in a real project. View snippet →

Limited availability Since 2020 67% global usage

This feature is not Baseline because it does not work in some of the most widely-used browsers.

137+
137+
Kinsta

Your first month is free

Managed WordPress hosting for faster sites.

Learn more

New CSS drops.

Join 600+ readers who've survived clearfix hacks.

ESC