grid

grid-area

Places a grid item into a named template area or into a specific span of rows and columns. It is the shorthand for grid-row-start / grid-column-start / grid-row-end / grid-column-end.

grid-area: <name> | <row-start> / <column-start> / <row-end> / <column-end>

Common values

Value Effect
header Assigns item to the named 'header' area
1 / 1 / 3 / 3 Spans rows 1-3 and columns 1-3
auto Item is placed automatically by the grid algorithm

Examples

.layout { display: grid; grid-template-areas: 'nav main' 'nav footer'; } .nav { grid-area: nav; }

Named-area layout with a sidebar

.hero { grid-area: 1 / 1 / 3 / -1; }

Spans two rows and all columns

.ad { grid-area: sidebar; }

Places element into named sidebar area

Gotcha

Named areas must be defined on the parent via grid-template-areas; unknown names simply do nothing.

Related properties

← All CSS properties · CSS selectors · Grid vs Flexbox