Container Queries — exercises and bug fixes
5 hands-on exercises and 5 find-the-bug challenges for the Container Queries lesson. Every one is checked automatically in the browser — write the code, run it, and the tests tell you what still fails.
Exercises(5)
- 1
Make an element a container
easy10 minLet #wrap be queried on its inline size.
- 2
Query the container
easy10 minWhen #wrap is 500px or narrower, make #text purple.
- 3
Name a container
easy10 minName #wrap "card" and query it by that name.
- 4
Use the container shorthand
easy10 minSet the name and type together with the container shorthand.
- 5
Restyle a component by its box
medium10 minIn a narrow card, stack #box and shrink #text.
Find the bug(5)
- 1
Fix the missing container-type
easy8 minNothing can be queried until the element opts in.
- 2
Fix the container that opted out
easy8 minThe default `normal` is not a queryable container.
- 3
Fix the name mismatch
easy8 minThe query names a container that does not exist.
- 4
Fix the shorthand separator
easy8 minThe container shorthand separates name and type with a slash.
- 5
Fix the element querying itself
easy8 minA container cannot be styled by its own query — put the type on the parent.
Ready to write the code?
The editor, the automatic checks and the worked solutions open up with an account.
Open the workspace