Challenge - 5 Problems
Aspect Ratio Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
❓ rendering
intermediate2:00remaining
What is the visible shape of this box?
Given the CSS below, what shape will the box appear as in the browser?
CSS
div {
aspect-ratio: 16 / 9;
width: 320px;
background-color: lightblue;
}Attempts:
2 left
💡 Hint
Aspect ratio controls the width to height ratio of the box.
✗ Incorrect
The aspect-ratio 16 / 9 means width is 16 units and height is 9 units. With width fixed at 320px, height is calculated as 320 * 9 / 16 = 180px, making a wide rectangle.
📝 Syntax
intermediate1:30remaining
Which CSS rule correctly sets a 4:3 aspect ratio?
Choose the CSS rule that correctly sets an element's aspect ratio to 4:3.
Attempts:
2 left
💡 Hint
The aspect-ratio property uses a slash (/) between numbers without quotes.
✗ Incorrect
The correct syntax uses a slash between numbers without quotes. Option C is correct. Option C reverses ratio. Options C and D use invalid syntax.
❓ layout
advanced2:00remaining
How does aspect-ratio affect a flex item with fixed width?
Consider a flex container with a child having fixed width and aspect-ratio set. What will be the child's height?
CSS
div.container { display: flex; } div.child { width: 200px; aspect-ratio: 1 / 1; background-color: coral; }
Attempts:
2 left
💡 Hint
Aspect ratio sets height based on width when height is not fixed.
✗ Incorrect
With width fixed at 200px and aspect-ratio 1 / 1, height is calculated as 200px to keep a square shape.
❓ accessibility
advanced1:30remaining
Why is using aspect-ratio helpful for accessibility?
Which reason best explains how aspect-ratio improves accessibility in web design?
Attempts:
2 left
💡 Hint
Think about how stable layouts help all users.
✗ Incorrect
Using aspect-ratio reserves space before content loads, preventing layout shifts. This stability helps screen readers and keyboard navigation by keeping focus and content predictable.
🧠 Conceptual
expert2:30remaining
What happens if both width and height are set along with aspect-ratio?
Given this CSS, what will be the final size of the box?
CSS
div {
width: 300px;
height: 200px;
aspect-ratio: 16 / 9;
background-color: lightgreen;
}Attempts:
2 left
💡 Hint
When both width and height are set, aspect-ratio is ignored.
✗ Incorrect
If both width and height are explicitly set, aspect-ratio is ignored and the box uses those exact dimensions.