0
0
CSSmarkup~20 mins

Grid gap in CSS - Practice Problems & Coding Challenges

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
Grid Gap Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
🧠 Conceptual
intermediate
1:30remaining
What does the gap property do in CSS Grid?
In a CSS Grid layout, what is the main purpose of the gap property?
AIt defines the size of each grid item.
BIt sets the space between grid items both in rows and columns.
CIt controls the padding inside each grid item.
DIt changes the background color of the grid container.
Attempts:
2 left
💡 Hint
Think about the space you see between boxes in a grid layout.
📝 Syntax
intermediate
1:30remaining
Which CSS code correctly sets a 20px gap between grid items?
You want to add a 20px gap between all grid items in a container. Which CSS snippet does this correctly?
CSS
.container {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  /* gap here */
}
Agap: 20px;
Bgrid-gap: 20px 20px 20px;
Cgap: 20px 20px;
Dgap: 20px 20px 20px 20px;
Attempts:
2 left
💡 Hint
The gap property accepts one or two values for rows and columns.
rendering
advanced
2:00remaining
What visual difference does gap: 10px 30px; create in a grid?
Given a grid container with gap: 10px 30px;, what will you see?
CSS
.container {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px 30px;
}
A10px space around the entire grid container.
B30px vertical space between rows and 10px horizontal space between columns.
C10px vertical space between rows and 30px horizontal space between columns.
DNo space between grid items.
Attempts:
2 left
💡 Hint
Remember the order of values in gap: first is row gap, second is column gap.
selector
advanced
1:30remaining
Which CSS selector targets the gap between grid items?
You want to style the space between grid items using CSS. Which selector or property affects this space?
AThe <code>gap</code> property on the grid container.
BThe <code>:gap</code> pseudo-class on grid items.
CThe <code>margin</code> property on grid items.
DThe <code>padding</code> property on the grid container.
Attempts:
2 left
💡 Hint
Think about which CSS property controls spacing between grid cells.
accessibility
expert
2:30remaining
How does using gap improve accessibility in grid layouts?
Why is it better for accessibility to use the CSS gap property instead of adding margins to grid items?
ABecause margins increase the font size of grid items.
BBecause margins cause grid items to be skipped by screen readers.
CBecause <code>gap</code> automatically adds ARIA labels to grid items.
DBecause <code>gap</code> maintains consistent spacing without affecting keyboard navigation or screen reader order.
Attempts:
2 left
💡 Hint
Think about how spacing affects focus and reading order.