CSS Variables Scope
Concept Check Medium
Question
Where should you define a CSS variable used across the entire page?
Hint
Think about the element that is the ancestor of all others.
Explanation
Defining a CSS custom property on :root (which represents the <html> element) makes it available to every element on the page through inheritance. You can also scope variables to specific elements for more localized overrides.
Related Resources
Related Lessons
Look up unfamiliar terms
A beginner-friendly glossary explains jargon in plain English — variables, functions, DOM, Promise, and more.
Decode error messages
Plain-English explanations of common errors — what they mean, why they happen, and how to fix them.
Build real projects
Apply what you learned by building guided projects with starter code and solutions.