Cascade & Inheritance — exercises and bug fixes
5 hands-on exercises and 5 find-the-bug challenges for the Cascade & Inheritance 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
Inherit a colour
easy10 minSet the colour on #parent so #box inherits red.
- 2
Let the later rule win
easy10 minTwo rules of equal weight — make the box blue by ordering.
- 3
Force inheritance
easy10 minBorders do not inherit — use the inherit keyword on #box.
- 4
Inherit font size
easy10 minSet 24px on the parent and let the box inherit it.
- 5
Override an inherited value
medium10 minParent is red, but the box itself must be green.
Find the bug(5)
- 1
Fix the earlier rule expected to win
easy8 minThe later rule overrides it — reorder so blue wins.
- 2
Fix the non-inheriting property
easy8 minBorder does not inherit automatically.
- 3
Fix the colour set on the wrong element
easy8 minThe colour is on the box but should come from the parent.
- 4
Fix the overridden override
easy8 minThe box's own colour is being lost to a later parent-scoped rule.
- 5
Fix the inherited font size
easy8 minThe size is set on the box rather than inherited from the parent.
Ready to write the code?
The editor, the automatic checks and the worked solutions open up with an account.
Open the workspace