0
0
CSSmarkup~20 mins

Grid vs flexbox in CSS - Practice Questions

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
Grid vs Flexbox Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
🧠 Conceptual
intermediate
2:00remaining
When to use Grid over Flexbox?
Which scenario best fits using CSS Grid instead of Flexbox?
ACentering a single item inside a container.
BAligning items in a single row horizontally.
CDistributing items evenly in a single column vertically.
DCreating a two-dimensional layout with rows and columns.
Attempts:
2 left
💡 Hint
Think about whether you need control over both rows and columns or just one direction.
📝 Syntax
intermediate
2:00remaining
Identify the correct Flexbox container syntax
Which CSS snippet correctly sets up a flex container that arranges items in a row and centers them horizontally and vertically?
Adisplay: flex; justify-content: center; align-items: center;
Bdisplay: grid; justify-content: center; align-items: center;
Cdisplay: flex; justify-items: center; align-content: center;
Ddisplay: flexbox; justify-content: center; align-items: center;
Attempts:
2 left
💡 Hint
Check the display property value and the correct properties for alignment in Flexbox.
layout
advanced
2:30remaining
Grid layout with named areas
Given the CSS below, what will be the visual layout of the grid areas?
CSS
.container {
  display: grid;
  grid-template-areas:
    "header header header"
    "sidebar content content"
    "footer footer footer";
  grid-template-columns: 1fr 2fr 1fr;
  grid-template-rows: auto 1fr auto;
}
AHeader spans all columns at bottom, sidebar on left top, content in middle top, footer on right top.
BHeader on left top, sidebar in middle top, content on right top, footer spans all columns at bottom.
CHeader spans all three columns on top, sidebar on left middle, content in middle and right middle, footer spans all columns at bottom.
DHeader spans all columns in middle row, sidebar and content below, footer on top.
Attempts:
2 left
💡 Hint
Look at how grid-template-areas define the layout row by row.
selector
advanced
2:00remaining
Selecting flex items with CSS selectors
Which CSS selector targets only the second flex item inside a flex container?
A.container :nth-of-type(2)
B.container > :nth-child(2)
C.container > div:nth-child(2)
D.container > .item:nth-child(2)
Attempts:
2 left
💡 Hint
Consider direct children and the correct pseudo-class for position.
accessibility
expert
3:00remaining
Improving accessibility in grid layouts
Which practice best improves keyboard navigation accessibility in a complex CSS Grid layout?
AUse semantic HTML elements and logical tab order matching visual grid order.
BAdd tabindex="-1" to all grid items to prevent tabbing.
CDisable keyboard navigation and rely on mouse only.
DUse only divs with role="grid" and no focus management.
Attempts:
2 left
💡 Hint
Think about how users navigate with keyboard and how HTML structure affects it.