Sass mainly uses two number types: unitless numbers (like 5, 10) and numbers with units (like 5px, 2em, 50%).
Click to reveal answer
intermediate
How does Sass handle arithmetic with different units?
Sass can add, subtract, multiply, and divide numbers with units if the units are compatible. For example, you can add 10px + 5px, but not 10px + 5em without conversion.
Click to reveal answer
beginner
What happens if you multiply a number with a unit by a unitless number in Sass?
The unit stays the same. For example, 5px * 2 results in 10px. The unitless number scales the value but does not change the unit.
Click to reveal answer
beginner
Name some common CSS units that Sass supports.
Common units include px (pixels), em (relative to font size), rem (root font size), % (percentage), vh and vw (viewport height and width).
Click to reveal answer
intermediate
Can Sass convert between different units automatically?
No, Sass does not convert units automatically. You must manually convert units or use functions to handle unit conversions.
Click to reveal answer
Which of these is a unitless number in Sass?
A50%
B10px
C5em
D10
✗ Incorrect
Only '10' has no unit, so it is unitless.
What is the result of 5px * 3 in Sass?
A15px
B5px3
C8px
D15
✗ Incorrect
Multiplying a number with a unit by a unitless number keeps the unit: 5px * 3 = 15px.
Can you add 10px + 5em directly in Sass?
ANo, units must be compatible
BYes, always
CYes, but only in SCSS syntax
DOnly if you use a special function
✗ Incorrect
Sass requires compatible units to add numbers directly.
Which unit represents a percentage in Sass?
Apx
B%
Cem
Drem
✗ Incorrect
The '%' symbol is used for percentages.
Does Sass automatically convert 1in to 96px?
AYes
BOnly in SCSS
CNo
DOnly with a plugin
✗ Incorrect
Sass does not convert units automatically; you must convert manually.
Explain the difference between unitless numbers and numbers with units in Sass.
Think about how Sass treats plain numbers versus numbers with px, em, %.
You got /4 concepts.
Describe how Sass handles arithmetic operations involving units.
Consider what happens when you add 10px + 5px versus 10px + 5em.
You got /4 concepts.
Practice
(1/5)
1. Which of the following is a valid Sass number with a unit?
easy
A. 20pixels
B. 12px
C. 15percent
D. 30ptx
Solution
Step 1: Understand Sass number units
Sass supports standard CSS units like px, %, em, rem, etc.
Step 2: Check each option for valid unit
12px uses a valid unit px. Others use invalid or misspelled units.
Final Answer:
12px -> Option B
Quick Check:
Valid CSS unit = 12px [OK]
Hint: Look for standard CSS units like px, %, em, rem [OK]
Common Mistakes:
Confusing 'percent' with '%' unit
Using non-standard unit names like 'pixels'
Misspelling units like 'ptx'
2. Which Sass number is written with correct syntax?
easy
A. 5em
B. 15 rems
C. 20 %
D. 10 px
Solution
Step 1: Check spacing between number and unit
Sass numbers must have no space between the number and unit.
Step 2: Validate each option
5em is correct with no space. Others have spaces or invalid units.
Final Answer:
5em -> Option A
Quick Check:
No space between number and unit = 5em [OK]
Hint: No spaces allowed between number and unit in Sass [OK]
Common Mistakes:
Adding space between number and unit
Using plural forms like 'rems'
Confusing unit syntax with CSS property values
3. What will be the output of this Sass code?
$width: 10px * 2;
.result {
width: $width;
}
medium
A. width: 10px2;
B. width: 10px;
C. width: 20px;
D. width: 20;
Solution
Step 1: Multiply number with unit by a unitless number
Multiplying 10px by 2 doubles the value but keeps the unit.
Step 2: Resulting value and unit
The result is 20px, which is valid CSS for width.
Final Answer:
width: 20px; -> Option C
Quick Check:
10px * 2 = 20px [OK]
Hint: Multiply unit number by unitless number keeps unit [OK]
Common Mistakes:
Concatenating number and unit as string
Losing unit after multiplication
Expecting unit to change or disappear
4. Identify the error in this Sass code:
$height: 50px + 10;
.box {
height: $height;
}
medium
A. Adding a unitless number to a number with unit causes error
B. Variable name cannot start with $
C. Missing semicolon after variable declaration
D. Units must be written in uppercase
Solution
Step 1: Check operation between numbers with and without units
Sass cannot add a unitless number to a number with units directly.
Step 2: Identify the error cause
Adding 50px and 10 (unitless) causes a unit mismatch error.
Final Answer:
Adding a unitless number to a number with unit causes error -> Option A
Quick Check:
Unit mismatch in addition = error [OK]
Hint: Cannot add unitless number to number with unit directly [OK]
5. You want to create a responsive padding that is 2rem on small screens and 5% on large screens using Sass variables. Which approach correctly defines and uses these units?