0
0
SASSmarkup~20 mins

CSS custom properties vs SASS variables - Practice Questions

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
CSS Variable Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
🧠 Conceptual
intermediate
1:30remaining
How do CSS custom properties behave differently from SASS variables?
Which statement correctly describes a key difference between CSS custom properties and SASS variables?
ACSS custom properties are only available during SASS compilation, while SASS variables exist in the browser.
BSASS variables can be updated by JavaScript after the page loads, but CSS custom properties cannot.
CSASS variables support inheritance in CSS selectors, but CSS custom properties do not.
DCSS custom properties can be changed dynamically in the browser at runtime, while SASS variables are fixed at compile time.
Attempts:
2 left
💡 Hint
Think about when each variable type is processed and if they can be changed after the page loads.
📝 Syntax
intermediate
1:30remaining
Identify the valid CSS custom property syntax
Which option shows the correct way to define and use a CSS custom property?
A:root { $main-color: #3498db; } .btn { color: var($main-color); }
B:root { --main-color: #3498db; } .btn { color: $main-color; }
C:root { --main-color: #3498db; } .btn { color: var(--main-color); }
D:root { --main-color = #3498db; } .btn { color: var(--main-color); }
Attempts:
2 left
💡 Hint
CSS custom properties start with two dashes and use var() to access.
rendering
advanced
2:00remaining
What color will the button text be?
Given this SASS and CSS code, what color will the button text appear in the browser?
SASS
$main-color: red;
:root {
  --main-color: blue;
}
.btn {
  color: $main-color;
  background-color: var(--main-color);
}
ARed text on blue background
BBlue text on blue background
CRed text on red background
DBlue text on red background
Attempts:
2 left
💡 Hint
Remember which variables are replaced during compilation and which are used by the browser.
selector
advanced
1:30remaining
Which selector correctly changes a CSS custom property for a specific element?
You want to change the CSS custom property --main-color only for buttons inside a <section>. Which CSS snippet does this correctly?
Asection button { --main-color: green; }
Bsection button { color: var(--main-color: green); }
Csection button { --main-color = green; }
Dsection button { $main-color: green; }
Attempts:
2 left
💡 Hint
CSS custom properties are set like normal CSS properties with two dashes.
accessibility
expert
2:30remaining
How can CSS custom properties improve accessibility?
Which approach best uses CSS custom properties to help users with visual impairments switch between color themes?
AUse SASS variables to define colors and recompile CSS for each theme.
BDefine color variables with CSS custom properties and change their values on a parent element when toggling themes.
CHardcode colors in CSS and use JavaScript to replace all color values inline when switching themes.
DUse inline styles on each element to set colors directly for each theme.
Attempts:
2 left
💡 Hint
Think about which method allows changing colors without recompiling or editing many elements.