Skip to main content

Sass: if()


this built-in if() function returns only one result from two possible outcomes.

The result of the function can be referred to the variable that may not be defined or to have further calculations.

It is written as if( expression, value1, value2 )

The .scss file below

h2 {
color: if( 1 + 1 == 2 , green , red);

and the .css below

h2 { 
color: green;

Table of Contents