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?
✗ 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?
✗ 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?
✗ Incorrect
CSS custom properties are accessed using the
var(--property-name) syntax.Which variable type supports calculations and functions during development?
✗ 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?
✗ 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.