Let #wrap be queried on its inline size.
Acceptance criteria
- 1.Let #wrap be queried on its inline size.
CSS Tutorial · CSS Responsive Design
These 10 tasks go with the Container Queries chapter. 5 of them ask you to build something small from scratch; 5 give you code that is already broken and ask you to work out why. Set aside about 90 minutes for the whole set, though you can do them in any order.
Nothing here is marked by a person. When you press Submit, the editor checks your code against the points listed under each task and tells you straight away what passed and what didn't (you need a free account to submit). If you get stuck, there are hints, and a worked solution once you've had a go. The first 2 tasks are free; the rest are part of the practice plan.
If it's been a while since you read the chapter, here is how it starts: “Adapt a component to the space provided by its container instead of the size of the viewport. You will establish named query containers, write size and style queries, use container-relative units, and decide when media queries remain appropriate.” .
1.Make an element a containerexercise · easy · 10 min
Let #wrap be queried on its inline size.
Passes when: Let #wrap be queried on its inline size.
2.Query the containerexercise · easy · 10 min · practice plan
When #wrap is 500px or narrower, make #text purple.
Passes when: When #wrap is 500px or narrower, make #text purple.
3.Name a containerexercise · easy · 10 min · practice plan
Name #wrap "card" and query it by that name.
Passes when: Name #wrap "card" and query it by that name.
4.Use the container shorthandexercise · easy · 10 min · practice plan
Set the name and type together with the container shorthand.
Passes when: Set the name and type together with the container shorthand.
5.Restyle a component by its boxexercise · medium · 10 min · practice plan
In a narrow card, stack #box and shrink #text.
Passes when: In a narrow card, stack #box and shrink #text.
6.Fix the missing container-typebug fix · easy · 8 min
Nothing can be queried until the element opts in.
Passes when: Nothing can be queried until the element opts in.
7.Fix the container that opted outbug fix · easy · 8 min · practice plan
The default `normal` is not a queryable container.
Passes when: The default `normal` is not a queryable container.
8.Fix the name mismatchbug fix · easy · 8 min · practice plan
The query names a container that does not exist.
Passes when: The query names a container that does not exist.
9.Fix the shorthand separatorbug fix · easy · 8 min · practice plan
The container shorthand separates name and type with a slash.
Passes when: The container shorthand separates name and type with a slash.
10.Fix the element querying itselfbug fix · easy · 8 min · practice plan
A container cannot be styled by its own query — put the type on the parent.
Passes when: A container cannot be styled by its own query — put the type on the parent.
Between them these tasks cover container-type, @container and Named containers.
Looking for a different chapter? See every practice set, or switch to the interview theory questions.