sass

Operators

Assignment Operator

Sass uses the colon (:) operator to assign values to variables.

Example

$foreColor: red;

p {
    color: $foreColor;
}

Arithmetic Operators

Sass supports the following standard arithmetic operators:

Operator Description
+ Addition
Subtraction
* Multiplication
/ Division
% Remainder

Examples

p {
    font-size: 16px + 4px; // 20px
}
h3 {
    width: 2px * 5 + 12px; // 22px
}
h2 {
    width: 8px + (12px / 2) * 3; // 26px
}

Normal order of operations applies as usual.

Comparison Operators

Sass supports all the usual comparison operators: <,>,==,!=,<=,>=.

Examples

(10px == 10) // Returns true

("3" == 3) // Returns false

$padding: 10px;
$padding <= 8px; // Returns false

This modified text is an extract of the original Stack Overflow Documentation created by the contributors and released under CC BY-SA 3.0 This website is not affiliated with Stack Overflow