Skip to content

CSS Grid

display: grid transforms all direct children into cells of a two-dimensional grid.

.container {
display: grid;
}

Define column and row tracks, often using functions like repeat() or minmax().


grid-auto-flow, grid-auto-columns/rows, and gap handle automatic item placement and spacing.


Explicit placement: grid-column / grid-row / grid-area

Section titled “Explicit placement: grid-column / grid-row / grid-area”

Exact positioning of elements in the grid using line numbers or named areas.


Alignment rules in Grid come from the Flexbox module, now shared (box‑alignment).


Advanced examples: fluid layout from 1 to 3 columns, 12‑column system, product auto-placement.


ConceptShort description
display: gridActivates the two-dimensional grid for direct children
grid-templateExplicitly defines columns, rows, or areas with repeat() / minmax()
Auto-placementAutomatically places items using grid-auto-flow and gap
Explicit placementgrid-column, grid-row, grid-area: precise control of the grid layout
Alignmentalign-items, justify-items, align-self shared with the Flexbox model
Responsive/grid layoutAdaptive grids, multi-column systems, named areas