Grid is ideal for two-dimensional layout where rows and columns both matter explicitly.
Grid strengths
- Dashboard/page regions.
- Card galleries with predictable tracks.
- Complex alignment without nested wrappers.
Important interview questions and answers
- Q: Why grid over flex for page shells?
A: Explicit row/column control across both axes. - Q: What does
1frrepresent?
A: Fraction of available free space. - Q: Common grid beginner mistake?
A: Hardcoding too many fixed tracks that break responsiveness.
Challenge
Two-column grid
- Create
grid-template-columns: 1fr 1frwithgap.
Done when: two equal columns appear without floats.