Grid Area Placement
Predict Output Medium
Question
How many columns does this grid have?
Code
.grid {
display: grid;
grid-template-columns: repeat(3, 1fr);
}
Hint
repeat(3, 1fr) creates 3 equal columns.
Explanation
grid-template-columns: repeat(3, 1fr) creates 3 equal-width columns, each taking 1/3 of the container width. The repeat() function is shorthand for writing 1fr 1fr 1fr. Grid items auto-flow into these columns. Rows are created automatically as needed unless grid-template-rows is specified.
Related Resources
Related Lessons
- CSS Grid
Learn CSS Grid layout.
Look up unfamiliar terms
A beginner-friendly glossary explains jargon in plain English — variables, functions, DOM, Promise, and more.
Decode error messages
Plain-English explanations of common errors — what they mean, why they happen, and how to fix them.
Build real projects
Apply what you learned by building guided projects with starter code and solutions.