Skip to content
Browse Tools
HomeToolsBlogGlossaryAboutContact
Browse All Tools
Development

CSS Grid Layout: The Complete Modern Guide

Master CSS Grid — from basic grids to complex layouts. Practical examples for every skill level.

CSS Grid Layout: The Complete Modern Guide

Grid vs Flexbox

Flexbox is one-dimensional — it handles either rows or columns. CSS Grid is two-dimensional and handles both simultaneously. Use Flexbox for component-level layouts and Grid for page-level layouts. In practice, most modern UIs use both.

Core Grid Concepts

display: grid creates a grid container. grid-template-columns: repeat(3, 1fr) creates three equal columns. The fr unit represents a fraction of the available space. gap sets the gutter between rows and columns.

Placing Items

grid-column: 1 / 3 spans from column line 1 to line 3. grid-area allows naming sections of the grid, enabling layout changes with just CSS. auto-fill creates as many columns as fit, while auto-fit collapses empty tracks.

Responsive Grid Patterns

The pattern grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)) creates a fully responsive grid that adjusts column count based on available width — with no media queries required.

Related Tools
JSON Formatter & Validator
Developer Tools
Base64 Encoder / Decoder
Developer Tools
Regex Tester
Developer Tools

Try 150+ Free Tools

No signup required. Everything runs in your browser, 100% private.

Browse All Tools

More Articles