Jump into concepts and practice - no test required
or
Recommended
Test this pattern10 questions across easy, medium, and hard to know if this pattern is strong
Recall & Review
beginner
What is a CSS custom property?
A CSS custom property is a variable defined directly in CSS using the syntax --property-name. It can be accessed and changed in the browser at runtime.
Click to reveal answer
intermediate
How do SASS variables differ from CSS custom properties?
SASS variables are defined in SASS files and replaced during compilation before the CSS is sent to the browser. CSS custom properties exist in the final CSS and can be changed dynamically in the browser.
Click to reveal answer
beginner
Show an example of defining and using a CSS custom property.
Can CSS custom properties be changed with JavaScript after the page loads?
Yes, CSS custom properties can be updated dynamically using JavaScript, allowing live style changes without reloading the page.
Click to reveal answer
intermediate
Why might you choose SASS variables over CSS custom properties?
Use SASS variables when you want to use variables during development for things like calculations or nesting, and when you don't need to change values dynamically in the browser.
Click to reveal answer
Which of these can be changed dynamically in the browser after the page loads?
ACSS custom properties
BSASS variables
CBoth CSS custom properties and SASS variables
DNeither CSS custom properties nor SASS variables
✗ Incorrect
CSS custom properties exist in the final CSS and can be changed dynamically with JavaScript. SASS variables are compiled away before the page loads.
Where are SASS variables replaced with actual values?
AIn the HTML file
BIn the browser at runtime
COnly when JavaScript runs
DDuring SASS compilation before sending CSS to the browser
✗ Incorrect
SASS variables are replaced during the compilation step before the CSS is sent to the browser.
How do you use a CSS custom property in your CSS code?
Acustom-property(--property-name)
Bvar(--property-name)
Cproperty-name()
D$property-name
✗ Incorrect
CSS custom properties are accessed using the var(--property-name) syntax.
Which variable type supports calculations and functions during development?
ASASS variables
BBoth support calculations
CCSS custom properties
DNeither support calculations
✗ Incorrect
SASS variables support calculations and functions during compilation, which CSS custom properties do not.
What is the correct way to define a SASS variable?
Avar(main-color): #333;
B--main-color: #333;
C$main-color: #333;
Dmain-color: #333;
✗ Incorrect
SASS variables start with a dollar sign, like $main-color: #333;.
Explain the main differences between CSS custom properties and SASS variables.
Think about when and where each variable type works.
You got /4 concepts.
Describe a situation where you would prefer to use CSS custom properties over SASS variables.
Consider dynamic style changes after page load.
You got /4 concepts.
Practice
(1/5)
1. Which of the following is true about CSS custom properties compared to SASS variables?
easy
A. SASS variables start with -- and are dynamic in the browser.
B. SASS variables start with -- and work in the browser at runtime.
C. CSS custom properties start with $ and are replaced before the browser sees CSS.
D. CSS custom properties start with -- and work in the browser at runtime.
Solution
Step 1: Identify CSS custom properties syntax
CSS custom properties always start with -- and are live in the browser, meaning they can be changed dynamically.
Step 2: Identify SASS variables syntax and behavior
SASS variables start with $ and are replaced during the build process, so they don't exist in the browser.
Final Answer:
CSS custom properties start with -- and work in the browser at runtime. -> Option D
Quick Check:
CSS variables = -- prefix and runtime [OK]
Hint: CSS vars use -- and work live; SASS vars use $ and compile away [OK]
Common Mistakes:
Confusing $ and -- prefixes
Thinking SASS variables work in the browser
Assuming CSS variables are replaced before runtime
2. Which is the correct way to declare a SASS variable for a color?
easy
A. primary-color: #3498db;
B. --primary-color: #3498db;
C. $primary-color: #3498db;
D. $primary-color == #3498db;
Solution
Step 1: Recall SASS variable syntax
SASS variables start with $ and use a colon : to assign values.
Step 2: Check each option
$primary-color: #3498db; uses correct syntax. --primary-color: #3498db; uses the CSS custom property prefix. primary-color: #3498db; omits the $ prefix. $primary-color == #3498db; uses double equals which is invalid.
Final Answer:
$primary-color: #3498db; -> Option C
Quick Check:
SASS variable = $name: value; [OK]
Hint: SASS vars start with $ and use colon for assignment [OK]
Common Mistakes:
Using -- instead of $ for SASS variables
Using == instead of : for assignment
Omitting $ prefix
3. Given the following code, what color will the text be in the browser?