0
0
CSSmarkup~10 mins

Clamp function in CSS - Interactive Code Practice

Choose your learning style9 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete the code to set a font size that clamps between 1rem and 3rem with a preferred size of 2vw.

CSS
font-size: clamp(1rem, [1], 3rem);
Drag options to blanks, or click blank then click option'
A50%
B20px
C2vw
D10em
Attempts:
3 left
💡 Hint
Common Mistakes
Using fixed units like px instead of relative units for the preferred size.
Putting the preferred size as the first or last value instead of the middle.
2fill in blank
medium

Complete the code to clamp the width between 200px and 600px with a preferred size of 50%.

CSS
width: clamp(200px, [1], 600px);
Drag options to blanks, or click blank then click option'
A10rem
B100vw
C400px
D50%
Attempts:
3 left
💡 Hint
Common Mistakes
Using fixed pixel values as the preferred size instead of relative units.
Mixing units incorrectly inside clamp().
3fill in blank
hard

Fix the error in the clamp function to correctly set margin between 10px and 50px with a preferred size of 5vw.

CSS
margin: clamp(10px, [1], 50px);
Drag options to blanks, or click blank then click option'
A5vh
B5vw
C5%
D5rem
Attempts:
3 left
💡 Hint
Common Mistakes
Using vh instead of vw for horizontal margin.
Using fixed units like rem or % which may not behave as expected.
4fill in blank
hard

Fill both blanks to clamp padding between 1rem and 4rem with a preferred size of 3vw.

CSS
padding: clamp([1], [2], 4rem);
Drag options to blanks, or click blank then click option'
A1rem
B2rem
C3vw
D5vw
Attempts:
3 left
💡 Hint
Common Mistakes
Swapping minimum and preferred values.
Using fixed units for preferred size.
5fill in blank
hard

Fill all three blanks to clamp line-height between 1.2, 1.5, and 2 with a preferred size of 1.5.

CSS
line-height: clamp([1], [2], [3]);
Drag options to blanks, or click blank then click option'
A1.2
B1.5
C2
D1.8
Attempts:
3 left
💡 Hint
Common Mistakes
Mixing the order of values.
Using values outside the allowed range.