The grid-area property

The grid-area property specifies an element name in a grid. These names are specified in the grid-template-areas property, which lists the element names in the order in which they need to be placed in the grid.

Syntax

cssselector {
  grid-area: element name;
}

Example

Let's name and position our elements in the grid:

html<div id="parent">
  <div id="elem1">1</div>
  <div id="elem2">2</div>
  <div id="elem3">3</div>
</div>
css#elem1 {
  grid-area: first;
}
#elem2 {
  grid-area: second;
}
#elem3 {
  grid-area: third;
}
#parent {
  display: grid;
  grid-template-areas: 'third second first';
  border: 2px solid #696989;
  padding: 10px;
}
#parent > div {
  padding: 10px;
  border: 1px solid #696989;
}

Результат:

See also