0
0
CSSmarkup~20 mins

Min and max functions in CSS - Practice Problems & Coding Challenges

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
CSS MinMax Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
📝 Syntax
intermediate
2:00remaining
What is the computed width of the box?
Consider this CSS code for a box. What will be the final width of the box in pixels when rendered in a browser?
CSS
div {
  width: min(50vw, 300px);
}
AThe width will always be 300px regardless of viewport size.
BThe width will be 50% of the viewport width or 300px, whichever is smaller.
CThe width will be 50% of the viewport width regardless of 300px.
DThe width will be the larger of 50vw and 300px.
Attempts:
2 left
💡 Hint
Remember, min() picks the smallest value from the list.
rendering
intermediate
2:00remaining
Which CSS rule sets the height to the larger value?
You want a box to have a height that is at least 200px but grows with 30% of the viewport height. Which CSS rule achieves this?
Aheight: max(200px, 30vh);
Bheight: min(200px, 30vh);
Cheight: 200px + 30vh;
Dheight: calc(max(200px, 30vh));
Attempts:
2 left
💡 Hint
Use the function that picks the bigger value.
selector
advanced
2:00remaining
Which CSS snippet correctly limits font size responsively?
You want the font size to be at least 1rem, but no more than 2rem, and scale with 5vw in between. Which CSS rule achieves this?
Afont-size: min(1rem, max(5vw, 2rem));
Bfont-size: max(min(1rem, 5vw), 2rem);
Cfont-size: min(max(1rem, 5vw), 2rem);
Dfont-size: max(1rem, min(5vw, 2rem));
Attempts:
2 left
💡 Hint
Think about nesting max and min to clamp a value between two limits.
layout
advanced
2:00remaining
What is the width of the container on a 600px wide screen?
Given this CSS, what is the container width in pixels when the viewport width is 600px?
CSS
.container {
  width: max(300px, min(50vw, 400px));
}
A300px
B300px if 50vw is less than 300px, else 50vw
C400px
D300px if 50vw is less than 300px, else 400px
Attempts:
2 left
💡 Hint
Calculate 50vw first, then apply min and max functions step by step.
accessibility
expert
2:00remaining
How do min() and max() help improve accessibility in responsive design?
Which statement best explains how using CSS min() and max() functions can improve accessibility for users on different devices?
AThey disable zoom on mobile devices to keep layout fixed.
BThey automatically add ARIA labels to elements based on size.
CThey allow content to resize within limits, preventing text from becoming too small or too large, improving readability.
DThey force all elements to have the same size regardless of screen.
Attempts:
2 left
💡 Hint
Think about how size limits affect user experience and readability.