Order base then theme, and let theme's blue win over base's red.
Acceptance criteria
- 1.Order base then theme, and let theme's blue win over base's red.
CSS Tutorial · Modern CSS Authoring
These 10 tasks go with the Cascade Layers 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: “Organize style origins into an explicit priority order without inflating selector specificity. You will define a layer order, place first- and third-party styles, understand unlayered rules, and see why important declarations reverse the order.” .
1.Declare the layer orderexercise · easy · 10 min
Order base then theme, and let theme's blue win over base's red.
Passes when: Order base then theme, and let theme's blue win over base's red.
2.Let a later layer winexercise · easy · 10 min · practice plan
Two layers, base then theme; theme should make #title green.
Passes when: Two layers, base then theme; theme should make #title green.
3.Beat a layer from outsideexercise · easy · 10 min · practice plan
Put red in a layer and let an unlayered orange rule win.
Passes when: Put red in a layer and let an unlayered orange rule win.
4.Beat specificity with layer orderexercise · easy · 10 min · practice plan
A low-specificity theme layer should still beat an id rule in base.
Passes when: A low-specificity theme layer should still beat an id rule in base.
5.Order three layersexercise · medium · 10 min · practice plan
reset, base, then theme — theme's teal should win.
Passes when: reset, base, then theme — theme's teal should win.
6.Fix the reversed layer orderbug fix · easy · 8 min
theme must be declared after base to win.
Passes when: theme must be declared after base to win.
7.Fix the missing at-signbug fix · easy · 8 min · practice plan
The rule is @layer.
Passes when: The rule is @layer.
8.Fix the rule trapped in a layerbug fix · easy · 8 min · practice plan
An unlayered rule is needed to beat the layer.
Passes when: An unlayered rule is needed to beat the layer.
9.Fix the undeclared orderbug fix · easy · 8 min · practice plan
Without an order declaration the layers fall back to source order, and base comes last.
Passes when: Without an order declaration the layers fall back to source order, and base comes last.
10.Fix the layer listed firstbug fix · easy · 8 min · practice plan
theme is listed before base, so it loses; it must come last.
Passes when: theme is listed before base, so it loses; it must come last.
Between them these tasks cover @layer, Layer order and Unlayered styles.
Looking for a different chapter? See every practice set, or switch to the interview theory questions.