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 is a grid container in CSS Grid?
A grid container is an HTML element with display: grid; or display: inline-grid;. It defines a grid layout where its child elements become grid items arranged in rows and columns.
Click to reveal answer
beginner
How do you make an element a grid container?
You set its CSS display property to grid or inline-grid. For example: display: grid;.
Click to reveal answer
beginner
What happens to the children of a grid container?
They become grid items. These items are placed automatically or manually into the grid's rows and columns defined by the container.
Click to reveal answer
intermediate
Which CSS properties define the rows and columns of a grid container?
The properties grid-template-columns and grid-template-rows define the number and size of columns and rows in the grid container.
Click to reveal answer
beginner
Why is using a grid container helpful for web layouts?
It helps organize content in a clean, flexible way using rows and columns. It adapts well to different screen sizes and makes complex layouts easier to build and maintain.
Click to reveal answer
Which CSS property turns an element into a grid container?
Adisplay: grid;
Bposition: grid;
Cfloat: grid;
Dgrid-template-columns: 1fr 1fr;
✗ Incorrect
Only display: grid; or display: inline-grid; makes an element a grid container.
What do the children of a grid container become?
ABlock elements
BGrid items
CFlex items
DInline elements
✗ Incorrect
Children of a grid container automatically become grid items.
Which property defines the number and size of columns in a grid container?
Agrid-auto-flow
Bgrid-template-rows
Cgrid-gap
Dgrid-template-columns
✗ Incorrect
grid-template-columns sets the columns; grid-template-rows sets the rows.
What is the default display value that creates a grid container?
Ablock
Binline-grid
Cgrid
Dflex
✗ Incorrect
The default grid container display is grid. inline-grid is also valid but less common.
Why use a grid container instead of floats for layout?
AGrid is easier for rows and columns layout
BFloats are faster
CGrid requires less CSS
DFloats work better on mobile
✗ Incorrect
Grid is designed for two-dimensional layouts with rows and columns, making it easier and more flexible than floats.
Explain what a grid container is and how it affects its child elements.
Think about how setting display changes the children arrangement.
You got /4 concepts.
Describe how you would define a grid with three equal columns using a grid container.
Use fractional units to divide space evenly.
You got /3 concepts.
Practice
(1/5)
1. What CSS property do you use to make an element a grid container?
easy
A. grid-template-columns: auto;
B. display: flex;
C. position: grid;
D. display: grid;
Solution
Step 1: Understand grid container basics
To create a grid layout, the container must have display: grid; set.
Step 2: Check other options
display: flex; creates a flexbox, not grid. position: grid; is invalid. grid-template-columns defines columns but does not make container a grid.
C. repeat() requires two arguments: count and size
D. grid-template-columns cannot use repeat()
Solution
Step 1: Check repeat() syntax
The repeat() function needs two arguments: number of times and size, e.g. repeat(3, 1fr).
Step 2: Identify the error
Here, only repeat(3) is given, missing the size argument, so it's invalid.
Final Answer:
repeat() requires two arguments: count and size -> Option C
Quick Check:
repeat() needs count and size [OK]
Hint: repeat() always needs count and size, like repeat(3, 1fr) [OK]
Common Mistakes:
Using repeat() with only one argument
Forgetting to specify display: grid;
Thinking repeat() is invalid in grid-template-columns
5. You want a grid container that has 2 columns: the first column is 150px wide, and the second column fills the remaining space. Which CSS is correct?
hard
A. display: grid; grid-template-columns: 150px auto;
B. display: grid; grid-template-columns: 150px 1fr;
C. display: grid; grid-template-columns: auto 150px;
D. display: grid; grid-template-columns: 1fr 150px;
Solution
Step 1: Understand fixed and flexible columns
150px is fixed width. To fill remaining space, use 1fr which means flexible fraction.
Step 2: Check options
display: grid; grid-template-columns: 150px auto; uses auto which sizes based on content, not remaining space. Options B and D put 150px in wrong column order.
Final Answer:
display: grid; grid-template-columns: 150px 1fr; -> Option B
Quick Check:
Fixed + flexible = 150px 1fr [OK]
Hint: Use 1fr for flexible space after fixed width [OK]