CSS Math Functions — exercises and bug fixes
5 hands-on exercises and 5 find-the-bug challenges for the CSS Math Functions 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
Add with calc
easy10 minMake #box 100px + 50px wide.
- 2
Subtract with calc
easy10 minMake #box 200px minus 40px wide.
- 3
Pick the smaller value
easy10 minUse min() so the width is the smaller of 400px and 250px.
- 4
Pick the larger value
easy10 minUse max() so the width is the larger of 120px and 300px.
- 5
Clamp a value
medium10 minClamp the width between 100px and 200px with a 500px preference.
Find the bug(5)
- 1
Fix the missing spaces
easy8 mincalc() requires spaces around + and -.
- 2
Fix min and max confused
easy8 minmin() picks the smallest — max() was intended here.
- 3
Fix the clamp argument order
easy8 minclamp() takes minimum, preferred, maximum in that order.
- 4
Fix the missing calc
easy8 minAn arithmetic expression needs calc() to be evaluated.
- 5
Fix the mismatched brackets
easy8 minThe closing bracket is missing, so the declaration is dropped.
Ready to write the code?
The editor, the automatic checks and the worked solutions open up with an account.
Open the workspace