Challenge - 5 Problems
Container Query Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
🧠 Conceptual
intermediate1:30remaining
What does a container query do in CSS?
Which statement best describes the purpose of a container query in CSS?
Attempts:
2 left
💡 Hint
Think about what 'container' means compared to 'viewport'.
✗ Incorrect
Container queries let you style an element based on its container's size, not the whole screen. This helps create more flexible designs.
📝 Syntax
intermediate1:30remaining
Identify the correct container query syntax in Sass
Which Sass code snippet correctly uses a container query to apply styles when the container is at least 30rem wide?
Attempts:
2 left
💡 Hint
Look for the correct parentheses and colon usage.
✗ Incorrect
The correct syntax uses parentheses around the condition with a colon separating property and value.
❓ rendering
advanced2:00remaining
What color will the box be when container width is 40rem?
Given the Sass code below, what color will the box have if its container is 40rem wide?
SASS
@container (min-width: 50rem) { .box { color: red; } } @container (min-width: 30rem) { .box { color: green; } } .box { color: black; }
Attempts:
2 left
💡 Hint
Check which container queries match 40rem width and which style applies last.
✗ Incorrect
At 40rem, the min-width: 30rem query applies, setting color to green. The 50rem query does not apply, so red is ignored.
❓ selector
advanced1:30remaining
Which selector correctly targets elements inside a container query?
In Sass, which selector inside a container query will style only direct child
elements of the container?
Attempts:
2 left
💡 Hint
Remember how Sass uses & to refer to the parent selector.
✗ Incorrect
The & symbol in Sass refers to the parent selector. Using & > p targets direct child <p> elements.
❓ accessibility
expert2:00remaining
How to ensure container queries do not harm accessibility?
Which practice helps maintain accessibility when using container queries for styling?
Attempts:
2 left
💡 Hint
Think about users with vision impairments and how styles affect readability.
✗ Incorrect
Accessibility requires good contrast and not relying only on color changes to communicate meaning, even when using container queries.