Encodera

Thanks for reading!

Donate to the site — we work hard for you.

HTML & CSS reference

grid-area

Places a grid item into a named area or between given lines.

Syntax

grid-area: name;

Values

ParameterTypeDescription
nameidentThe name of an area from `grid-template-areas`.
row / column / row-end / column-endlinesLine numbers: `1 / 1 / 3 / 3`.

Examples

Items placed by area names, regardless of their order in the markup:

<style>
  .grid { display: grid; grid-template-columns: repeat(3, 1fr); grid-template-areas: "a a b"; gap: 6px; }
  .grid div { padding: 8px; background: peachpuff; }
</style>
 
<div class="grid">
  <div style="grid-area: b;">Placed in b</div>
  <div style="grid-area: a;">Placed in a — two columns</div>
</div>

Notes

The area name is written without quotes in grid-area and in quotes in grid-template-areas.

See also

Related recipes

In the tutorial

  • Grid lines and areas — How to put an item in the right place of a grid — line numbers, grid-column and grid-row, span, named areas with grid-template-areas.

Thanks for reading!

Donate to the site — we work hard for you.