Interview Question

How do you create a CSS grid layout?

Set display:grid, define tracks, and let items occupy the grid.

💡 Concept ✅ Quick Revision 🎨 CSS

Answer

Create a grid layout by establishing a grid container and defining tracks. • grid-template-columns and grid-template-rows define explicit tracks. • gap creates spacing between tracks. • Use responsive track functions when item count or width can change.

💡 Simple Example

.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(16rem, 1fr)); gap: 1rem; }

⚡ Quick Revision

Set display:grid, define tracks, and let items occupy the grid.