The grid container

Adding display: grid to a parent element turns its children into grid items. Use the controls below to see how grid-template-columns, grid-template-rows, and gap shape the layout.

grid-template-columns Defines column widths
grid-template-rows Defines row heights
gap Space between cells
8px


  

Spanning columns and rows

Grid items can stretch across multiple columns or rows using grid-column and grid-row. Select an item below, then change its start line and end span.

Edit item:
grid-column start / end
/
grid-row start / end
/


  

Named template areas

grid-template-areas lets you sketch your layout with named zones. Each name then maps directly to an element via grid-area. A full stop (.) marks an empty cell.

grid-template-areas Choose a layout pattern

    

Aligning items inside the grid

Control how items sit within their cells with justify-items (horizontal) and align-items (vertical). Use justify-content / align-content to position the whole grid inside its container.

justify-items Horizontal alignment of all items
align-items Vertical alignment of all items

justify-content Horizontal alignment of the whole grid
align-content Vertical alignment of the whole grid


  
Web Design Home