Challenge - 5 Problems
Theme Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
🧠 Conceptual
intermediate2:00remaining
What is the purpose of CSS custom properties in theme implementation?
CSS custom properties (variables) are often used in themes. What is their main benefit when creating a theme?
Attempts:
2 left
💡 Hint
Think about how you can change a color in many places by changing just one value.
✗ Incorrect
CSS custom properties let you define values like colors once and reuse them. Changing the variable changes all uses, making theme switching easy.
📝 Syntax
intermediate2:00remaining
Which CSS snippet correctly defines a dark theme color variable?
You want to define a dark theme background color using a CSS custom property named --bg-color. Which snippet is correct?
Attempts:
2 left
💡 Hint
Remember custom properties start with two dashes and are inside a selector.
✗ Incorrect
Custom properties must start with -- and be inside a selector like :root. The correct syntax is :root { --bg-color: #121212; }.
❓ rendering
advanced2:00remaining
What color will the background be when this CSS is applied?
Given the CSS below, what will be the background color of the element?
CSS
:root {
--bg-color: white;
}
[data-theme="dark"] {
--bg-color: black;
}
body {
background-color: var(--bg-color);
}Attempts:
2 left
💡 Hint
Think about which CSS rule applies when the data-theme attribute is missing.
✗ Incorrect
The :root defines --bg-color as white by default. The dark theme only applies if data-theme="dark" is set. Without it, background is white.
❓ selector
advanced2:00remaining
Which CSS selector applies styles only when dark theme is active?
You want to style all paragraphs with a light text color only when the dark theme is active using the data-theme attribute on . Which selector is correct?
Attempts:
2 left
💡 Hint
The data-theme attribute is on the element, not on paragraphs.
✗ Incorrect
The attribute selector html[data-theme="dark"] p targets paragraphs inside when data-theme is dark. Other options look for the attribute on paragraphs or use a class not set.
❓ accessibility
expert2:00remaining
How to ensure theme colors meet accessibility contrast standards?
When implementing a dark theme, what is the best way to ensure text colors meet accessibility contrast requirements?
Attempts:
2 left
💡 Hint
Accessibility means text must be easy to read against backgrounds.
✗ Incorrect
Accessibility guidelines recommend a minimum contrast ratio between text and background. Using a contrast checker tool helps pick colors that meet these standards.