The two-dimensional layout system for the web
CSS Grid Layout is a powerful two-dimensional layout system that lets you create complex web designs with rows and columns. Unlike Flexbox which is one-dimensional, Grid allows precise control over both dimensions simultaneously.
The parent element that becomes a grid when you set display: grid
or display: inline-grid
.
The direct children of the grid container. These automatically become grid items.
The dividing lines that make up the structure of the grid. They can be vertical (column lines) or horizontal (row lines).
The space between two adjacent grid lines (essentially your columns and rows).
Rectangular space surrounded by four grid lines. You can name these areas for easier placement.
Property | Description |
---|---|
grid-template-columns | Defines the columns of the grid |
grid-template-rows | Defines the rows of the grid |
grid-template-areas | Defines named grid areas |
grid-gap / gap | Sets the gap between rows and columns |
grid-column | Positions an item along the column axis |
grid-row | Positions an item along the row axis |
justify-items | Aligns items along the row axis |
align-items | Aligns items along the column axis |