Open In App

SASS | String Operators

Sass supports some operators that can be used to generate strings.

Example:






@debug "Geeks" + "forGeeks"

Output:

"GeeksforGeeks"




@debug Geeks + forGeeks

Output:



GeeksforGeeks




@debug #{20px + 10px} / 50px

Output:

30px/50px




@debug Geeks - for - Geeks

Output:

Geeks-for-Geeks

The above operators are not only used for strings but for any values that you can code in CSS. But, you must know about the following exceptions to this:




@debug "Elapsed time: " + 40s

Output:

"Elapsed time: 40s"




@debug true + " is a boolean value"

Output:

"true is a boolean value"

Note: Always try to use interpolation to create strings as they are cleaner and clearer, rather than using the operators. Unary Operators For some historical reasons, Sass also supports / and – as unary operators that take only a single value:




@debug / geeks

Output:

/geeks




@debug - geeks

Output:

-geeks

Article Tags :