Jump into concepts and practice - no test required
or
Recommended
Test this pattern10 questions across easy, medium, and hard to know if this pattern is strong
Recall & Review
beginner
What does the grid-gap property do in CSS Grid?
It adds space between rows and columns inside a CSS Grid container, creating gaps between grid items.
Click to reveal answer
beginner
How do you set different gaps for rows and columns in CSS Grid?
Use grid-gap with two values: the first for row gap, the second for column gap. For example, grid-gap: 10px 20px; means 10px row gap and 20px column gap.
Click to reveal answer
intermediate
What is the modern property that replaced grid-gap?
The gap property is the modern standard that works for CSS Grid and Flexbox. It replaces grid-gap.
Click to reveal answer
beginner
Can grid-gap accept length units other than pixels?
Yes, it accepts any CSS length units like rem, em, %, or vh to control the gap size responsively.
Click to reveal answer
beginner
Does grid-gap add space inside grid items or between them?
grid-gap adds space only between grid items, not inside them. It separates the items visually without changing their size.
Click to reveal answer
What does grid-gap: 15px 30px; do?
ASets 15px gap for both rows and columns
BSets 15px gap between rows and 30px gap between columns
CSets 30px gap between rows and 15px gap between columns
DSets 30px gap for both rows and columns
✗ Incorrect
grid-gap first value is row gap, second is column gap.
Which property is the modern replacement for grid-gap?
Agap
Bgrid-spacing
Cgrid-margin
Dspace-between
✗ Incorrect
gap works for both CSS Grid and Flexbox and replaces grid-gap.
If you want equal space between all grid items, which is correct?
Agrid-gap: 20px 10px;
Bgrid-gap: 10px 20px;
Cgrid-gap: 20px;
Dgrid-gap: 0;
✗ Incorrect
One value sets equal gap for rows and columns.
Does grid-gap add space inside each grid item?
ANo, it removes space between items
BYes, it adds padding inside items
CYes, it adds margin inside items
DNo, it adds space only between items
✗ Incorrect
grid-gap only creates space between grid items, not inside them.
Which units can you use with grid-gap?
Apx, rem, em, %, vh
BOnly px
COnly % and px
DOnly em and rem
✗ Incorrect
grid-gap accepts any valid CSS length units.
Explain how to create space between rows and columns in a CSS Grid layout.
Think about how you separate items visually in a grid.
You got /3 concepts.
Describe the difference between grid-gap and padding inside grid items.
Consider where the space appears relative to the grid items.
You got /3 concepts.
Practice
(1/5)
1. What does the CSS property gap do in a grid layout?
easy
A. It sets the size of grid items.
B. It changes the background color of grid items.
C. It hides grid items from view.
D. It adds space between grid items without extra margins.
Solution
Step 1: Understand the purpose of gap
The gap property is designed to add space between grid items easily.
Step 2: Compare with other options
Options A, B, and D describe unrelated effects like size, color, or visibility, which gap does not control.
Final Answer:
It adds space between grid items without extra margins. -> Option D
Quick Check:
Grid gap = space between items [OK]
Hint: Remember: gap = space between grid cells [OK]
Common Mistakes:
Confusing gap with padding or margin
Thinking gap changes item size
Assuming gap affects background color
2. Which of the following is the correct syntax to set a 10px gap between rows and 20px gap between columns in a CSS grid?
easy
A. gap: 10px 20px;
B. gap: 20px 10px;
C. gap: 10px;
D. gap: 10px, 20px;
Solution
Step 1: Understand gap syntax with two values
The first value sets the row gap, the second sets the column gap. So gap: 10px 20px; means 10px row gap and 20px column gap.
Step 2: Check other options for syntax errors or wrong order
gap: 20px 10px; reverses the order (20px row, 10px column). gap: 10px; sets only one value (both gaps equal). gap: 10px, 20px; uses a comma which is invalid syntax.
Final Answer:
gap: 10px 20px; -> Option A
Quick Check:
gap: row column [OK]
Hint: First gap is row, second is column, no commas [OK]
Common Mistakes:
Swapping row and column values
Using commas between values
Using only one value when two are needed
3. Given this CSS code, what is the horizontal space between grid items?
The gap property has two values: 10px and 20. The second value lacks units (like px), which is invalid.
Step 2: Understand CSS unit requirements
CSS requires units for length values except zero. Missing units cause the property to be ignored, so no gap appears.
Final Answer:
The second gap value is missing units. -> Option A
Quick Check:
All length values need units except zero [OK]
Hint: Always add units (px, em) to gap values except zero [OK]
Common Mistakes:
Forgetting units on numeric values
Assuming gap works without units
Confusing gap with margin or padding
5. You want a grid with 4 columns and 3 rows. You want 1rem gap between rows and 2rem gap between columns. Which CSS code correctly sets this with accessibility and responsive design in mind?