CSS Variables and Custom Properties Quiz

Create an account and save your quiz results

Login and save your results

OR

Question 1/15

CSS variables can be animated using CSS transitions. True or false?

Select your answer

Question 2/15

Which preprocessor feature can CSS variables provide better flexibility than?

Select your answer

Question 3/15

Which properties cannot utilize CSS variables?

Select your answer

Question 4/15

Can CSS variables be used within JavaScript?

Select your answer

Question 5/15

Where can CSS custom properties be defined?

Select your answer

Question 6/15

How would you set a default for a CSS variable within a class if it's not defined elsewhere?

Select your answer

Question 7/15

Which of these is NOT a valid fallback mechanism when using CSS variables?

Select your answer

Question 8/15

What is a potential downside of heavily using CSS variables for every stylized element?

Select your answer

Question 9/15

How does the cascade handle CSS variables?

Select your answer

Question 10/15

What happens if a CSS variable is reassigned within a context under
:root
?

Select your answer

Question 11/15

What is the scope of CSS variables declared inside a media query?

Select your answer

Question 12/15

What is the correct syntax for declaring a CSS variable?

Select your answer

Question 13/15

Can CSS custom properties be nested like SASS variables?

Select your answer

Question 14/15

Can CSS custom properties interact with hardware-accelerated transitions?

Select your answer

Question 15/15

What happens if you use a CSS variable that has not been defined?

Select your answer

Your Results

You did not answer any questions correctly.

Your Answers

Question 1/15
😊 Your answer was correct 🙁 Your answer was incorrect
CSS variables can be animated using CSS transitions. True or false?

Available answers

CSS variables themselves cannot be directly animated. However, the properties using them can be transitioned if the variable changes during a transition context.
Question 2/15
😊 Your answer was correct 🙁 Your answer was incorrect
Which preprocessor feature can CSS variables provide better flexibility than?

Available answers

CSS variables allow for dynamic changes, unlike static preprocessor variables, which are beneficial for global theming and runtime adjustments.
Question 3/15
😊 Your answer was correct 🙁 Your answer was incorrect
Which properties cannot utilize CSS variables?

Available answers

While CSS variables can be used for most properties, they cannot be employed within media queries as part of their value set.
Question 4/15
😊 Your answer was correct 🙁 Your answer was incorrect
Can CSS variables be used within JavaScript?

Available answers

Using JavaScript's
getComputedStyle()
method, you can retrieve the value of CSS properties, including custom properties.
Question 5/15
😊 Your answer was correct 🙁 Your answer was incorrect
Where can CSS custom properties be defined?

Available answers

CSS custom properties can be defined within any CSS selector, including
:root
, id, class, or any other selector.
Question 6/15
😊 Your answer was correct 🙁 Your answer was incorrect
How would you set a default for a CSS variable within a class if it's not defined elsewhere?

Available answers

To set a fallback value for a CSS variable, use
var(--variable-name, default-value)
which applies the default if the variable is not set.
Question 7/15
😊 Your answer was correct 🙁 Your answer was incorrect
Which of these is NOT a valid fallback mechanism when using CSS variables?

Available answers

The option
if (var(--color)) then #000;
is not valid CSS syntax. Instead, use the
var()
function with a fallback value.
Question 8/15
😊 Your answer was correct 🙁 Your answer was incorrect
What is a potential downside of heavily using CSS variables for every stylized element?

Available answers

Widespread use of CSS variables can complicate debugging, as tracing variable values throughout a document can become complex if not well-organized.
Question 9/15
😊 Your answer was correct 🙁 Your answer was incorrect
How does the cascade handle CSS variables?

Available answers

CSS variables follow the same specificity rules as other CSS properties. Variables defined in more specific selectors will override those defined in less specific ones.
Question 10/15
😊 Your answer was correct 🙁 Your answer was incorrect
What happens if a CSS variable is reassigned within a context under <pre><code>:root</code></pre>?

Available answers

Reassigning a custom property value inside
:root
within a context like a media query or smaller scope affects the property only within that context.
Question 11/15
😊 Your answer was correct 🙁 Your answer was incorrect
What is the scope of CSS variables declared inside a media query?

Available answers

CSS variables declared inside a media query are scoped to that media query and only affect styles within that media context.
Question 12/15
😊 Your answer was correct 🙁 Your answer was incorrect
What is the correct syntax for declaring a CSS variable?

Available answers

CSS variables, also known as custom properties, are declared with the syntax
--variable-name: value;
.
Question 13/15
😊 Your answer was correct 🙁 Your answer was incorrect
Can CSS custom properties be nested like SASS variables?

Available answers

CSS custom properties are always flat and cannot inherently support nesting as SASS does.
Question 14/15
😊 Your answer was correct 🙁 Your answer was incorrect
Can CSS custom properties interact with hardware-accelerated transitions?

Available answers

Custom properties themselves are not hardware-accelerated but properties referencing them can be transitioned which may use hardware acceleration if applicable.
Question 15/15
😊 Your answer was correct 🙁 Your answer was incorrect
What happens if you use a CSS variable that has not been defined?

Available answers

If a CSS variable is undefined and a fallback value is provided, the property will use that fallback value. Without a fallback, the property behaves as though it has the initial value.