0
0
SASSmarkup~5 mins

CSS custom properties vs SASS variables - Quick Revision & Key Differences

Choose your learning style9 modes available
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.
Define: :root { --main-color: #3498db; }<br>Use: color: var(--main-color);
Click to reveal answer
intermediate
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
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
How do you use a CSS custom property in your CSS code?
Acustom-property(--property-name)
Bvar(--property-name)
Cproperty-name()
D$property-name
Which variable type supports calculations and functions during development?
ASASS variables
BBoth support calculations
CCSS custom properties
DNeither support calculations
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;
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.