0
0
CSSmarkup~20 mins

Flex wrap in CSS - Practice Problems & Coding Challenges

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
Flex Wrap Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
🧠 Conceptual
intermediate
2:00remaining
What does flex-wrap: wrap; do in a flex container?
Choose the correct description of the effect of flex-wrap: wrap; on flex items inside a flex container.
AIt centers all flex items horizontally inside the container.
BIt forces all flex items to stay on a single line, shrinking them if needed.
CIt allows flex items to move to the next line if they don't fit in one line.
DIt hides any flex items that don't fit in the container's width.
Attempts:
2 left
💡 Hint
Think about what happens when there are too many items to fit in one row.
📝 Syntax
intermediate
2:00remaining
Which CSS snippet correctly enables wrapping of flex items?
Select the CSS code that correctly applies wrapping behavior to a flex container.
CSS
div.container {
  display: flex;
  /* Which line below is correct? */
}
Aflex-wrap: wrap;
Bflex-wrap: nowrap;
Cflex-wrap: true;
Dwrap-flex: true;
Attempts:
2 left
💡 Hint
The property name is flex-wrap and the value to allow wrapping is wrap.
rendering
advanced
2:30remaining
What will be the visible layout result of this CSS?
Given the CSS below, how will the flex items be arranged visually in the browser?
CSS
div.container {
  display: flex;
  flex-wrap: wrap;
  width: 300px;
  border: 1px solid black;
}

div.item {
  flex: 0 0 140px;
  height: 50px;
  background-color: lightblue;
  margin: 5px;
}
AItems overlap each other inside the container.
BAll items in one row, shrinking to fit inside 300px.
CItems stacked vertically in a single column.
DTwo items per row, wrapping to next line after two items.
Attempts:
2 left
💡 Hint
Each item is 140px wide plus margin, container is 300px wide.
selector
advanced
2:30remaining
Which CSS selector targets only flex items that wrap to the next line?
You want to style only the flex items that appear on the second line after wrapping. Which selector will select those items?
Adiv.container > div.item:nth-child(n+3)
Bdiv.container > div.item:first-child
Cdiv.container > div.item:last-child
Ddiv.container > div.item:nth-child(2)
Attempts:
2 left
💡 Hint
Items that wrap to the next line start from the third item if two fit per line.
accessibility
expert
3:00remaining
How does using flex-wrap: wrap; affect keyboard navigation and accessibility?
Consider a flex container with many items that wrap onto multiple lines. What is the best practice to ensure keyboard users can navigate items logically?
ADisable wrapping to keep all items on one line for simpler navigation.
BEnsure the DOM order matches the visual order so tabbing moves through items in reading order.
CAdd ARIA roles to each flex item to force screen readers to read them in visual order.
DUse <code>tabindex="-1"</code> on wrapped items to skip them in keyboard navigation.
Attempts:
2 left
💡 Hint
Think about how keyboard users move through content and how DOM order affects that.