coderef

CSS Grid

Visual cheat sheet for CSS Grid Layout — every property with live previews you can copy.

Click any example to copy its CSS.

Grid container

display

Makes the element a grid container; its direct children become grid items.

grid-template-columns

Defines the number and size of the columns.

grid-template-rows

Defines the number and size of the rows.

grid-template-areas

Names regions of the grid; items are placed with grid-area.

gap

Sets the gutters between rows and columns.

justify-items

Aligns every item inside its cell along the row (inline) axis.

align-items

Aligns every item inside its cell along the column (block) axis.

place-items

Shorthand for align-items and justify-items.

justify-content

Positions the whole grid along the row axis when it is smaller than its container.

align-content

Positions the whole grid along the column axis when it is smaller than its container.

grid-auto-flow

Controls how items without an explicit position are placed.

grid-auto-rows

Sizes rows that are created implicitly.

Grid items

grid-column

Places an item between column lines, or spans it across columns.

grid-row

Places an item between row lines, or spans it across rows.

grid-area

Shorthand for row-start / column-start / row-end / column-end, or a named area.

justify-self

Aligns a single item inside its cell along the row axis.

align-self

Aligns a single item inside its cell along the column axis.

place-self

Shorthand for align-self and justify-self.

order

Changes the order in which an auto-placed item appears.