Predict CSS Variable Output
Predict Output Easy
Question
What is the computed color value of the paragraph?
Code
:root {
--main-color: #2563eb;
}
p {
color: var(--main-color);
}
Hint
var() resolves to the value defined for the custom property.
Explanation
CSS custom properties (variables) are resolved at use-site. var(--main-color) looks up the value defined on :root, which is #2563eb. The paragraph's computed color is #2563eb.
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.