CSS grid-area Property

Beginner
⏱️ 7 min read
📚 Updated: Jun 2026
🎯 4 Examples
Layout

What You’ll Learn

The grid-area property places a grid item by line numbers or assigns it to a named region in your layout.

01

Line numbers

Row & column.

02

Named areas

header, main.

03

Span cells

Cover 2×2.

04

Shorthand

Four values.

05

auto

Default flow.

06

Placement

Item control.

Introduction

The grid-area property in CSS is used to define a grid item's size and location within a grid layout. It is a shorthand property that can combine grid-row-start, grid-column-start, grid-row-end, and grid-column-end.

This property provides an efficient way to place and size grid items, making it easier to design complex grid layouts.

Definition and Usage

Apply grid-area on a child of a grid container (an element with display: grid). Use line numbers when you need precise control over which cells an item covers. Use a name like grid-area: header when the parent defines regions with grid-template-areas.

💡
Beginner Tip

Grid lines are numbered starting at 1, not 0. Line 1 is the left or top edge of the grid. So grid-area: 2 / 1 / 4 / 3 starts at row line 2 and ends at row line 4.

📝 Syntax

The syntax for the grid-area property can take two forms: the shorthand form or using grid line names.

Shorthand Syntax

syntax-lines.css
element {
  grid-area: row-start / column-start / row-end / column-end;
}
  • row-start — The line where the item's row starts.
  • column-start — The line where the item's column starts.
  • row-end — The line where the item's row ends.
  • column-end — The line where the item's column ends.

Line Names Syntax

syntax-name.css
element {
  grid-area: grid-area-name;
}

grid-area-name is the name of the grid area defined by the grid-template-areas property on the container.

grid-area: 2 / 1 / 4 / 3; grid-area: header; grid-area: 1 / 1 / span 2 / span 2;

Default Value

The default value for grid-area is auto / auto / auto / auto, which means the grid item will be placed in the next available cell according to the grid's flow.

Syntax Rules

  • Applies to grid items (children of a grid container), not the container itself.
  • Slash-separated values follow the order: row-start / column-start / row-end / column-end.
  • Omitted values default to auto.
  • A single name must match a region in the parent's grid-template-areas.
  • Shorthand for grid-row-start, grid-column-start, grid-row-end, and grid-column-end.

⚡ Quick Reference

QuestionAnswer
Initial valueauto (all sides)
Applies toGrid items
InheritedNo
Line number formrow-start / col-start / row-end / col-end
Named area formgrid-area: area-name;

💎 Property Values

ValueDescription
row-start / column-start / row-end / column-endSpecifies the lines where the grid item's row and column start and end
grid-area-nameSpecifies a named area defined by the grid-template-areas property
autoLets the browser place the item automatically along that axis
span nSpans across n rows or columns from the start line

👀 Live Preview

One item spanning rows 2–4 and columns 1–3 with grid-area: 2 / 1 / 4 / 3:

2
3
4
Item 1 (spans 2×2)
6
8
9

Examples Gallery

Place an item spanning a 2×2 area with line numbers, then explore named areas, span syntax, and a full-width hero section.

🔢 Line Placement

Start with the reference example — Item 1 spanning from row 2 to 4 and column 1 to 3.

Example 1 — Spanning with Line Numbers

Use grid-area: 2 / 1 / 4 / 3 to cover a 2×2 region.

grid-area-lines.css
.container {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  grid-template-rows: repeat(3, 100px);
  gap: 10px;
}

.item {
  grid-area: 2 / 1 / 4 / 3;
}
Try It Yourself

How It Works

Item 1 spans from row line 2 to row line 4 and from column line 1 to column line 3, effectively covering a 2×2 area in the grid.

Example 2 — Named Grid Areas

Assign items to header, sidebar, and main regions using area names.

grid-area-named.css
header { grid-area: header; }
aside { grid-area: sidebar; }
main { grid-area: main; }
Try It Yourself

How It Works

Each element's grid-area name matches a region defined in the parent's grid-template-areas declaration.

📈 Span & Hero Layouts

Use span keywords and full-width placement for larger layout sections.

Example 3 — Spanning Rows and Columns

Start at line 1 and span 2 rows and 3 columns with the span keyword.

grid-area-span.css
.featured {
  grid-area: 1 / 1 / span 2 / span 3;
}
Try It Yourself

How It Works

span 2 and span 3 tell the item to stretch across two rows and three columns from the starting lines.

Example 4 — Full-Width Hero Section

Place a hero banner in a named area that spans the full grid width.

grid-area-hero.css
.layout {
  grid-template-areas:
    "hero hero"
    "content sidebar";
}

.hero { grid-area: hero; }
Try It Yourself

How It Works

The hero area name appears twice in the first row of grid-template-areas, so the hero element stretches across both columns.

♿ Accessibility

  • Keep logical DOM order even when grid-area visually repositions items.
  • Use semantic HTML (header, main, nav) alongside named areas.
  • Test keyboard focus order when grid placement changes on responsive breakpoints.
  • Do not rely on position alone to convey meaning or hierarchy.
  • Ensure readable content width in spanned grid cells on large screens.

🧠 How grid-area Works

1

Parent defines the grid

The container sets columns, rows, and optional grid-template-areas.

Grid container
2

Item gets grid-area

You set line numbers or a name on the child element to target its placement.

Declaration
3

Browser maps to cells

The item stretches across the rows and columns bounded by the start and end lines.

Placement
=

Precise item placement

Grid items occupy exactly the cells or named regions you specify.

🖥 Browser Compatibility

The grid-area property is well-supported in modern browsers, including recent versions of Chrome, Firefox, Safari, Edge, and Opera. Test grid layouts across browsers when using complex placement.

Baseline · Universal support

grid-area everywhere

Line numbers and named areas work in every major modern browser.

97% Modern browser support
Google Chrome 57+ · Desktop & Mobile
Full support
Mozilla Firefox 52+ · Desktop & Mobile
Full support
Apple Safari 10.1+ · macOS & iOS
Full support
Microsoft Edge 16+ · 79+ Chromium
Full support
Opera 44+
Full support
grid-area property 97% supported

Bottom line: grid-area is safe for modern projects. Pair with display: grid on the parent container.

🎉 Conclusion

The grid-area property is a powerful tool for creating flexible and complex grid layouts in CSS. By using this property, you can precisely control the placement and sizing of grid items, allowing for more creative and organized web designs.

Experiment with different grid configurations and see how grid-area can enhance your layout designs. Start with line numbers for spanning cells, then use named areas for readable page layouts.

💡 Best Practices

✅ Do

  • Use named areas for page layouts
  • Count grid lines from 1, not 0
  • Pair with grid-template-areas on parent
  • Use span for readable stretching
  • Keep DOM order logical for accessibility

❌ Don’t

  • Apply grid-area without a grid parent
  • Rely on visual order over DOM order
  • Use mismatched area names
  • Overlap items unintentionally
  • Forget mobile layout reflow

Key Takeaways

Knowledge Unlocked

Five things to remember about grid-area

Use these points when placing grid items.

5
Core concepts
auto 02

Default auto

Auto flow.

Default
2/1/4/3 03

Line numbers

Four values.

Syntax
name 04

Named areas

header, main.

Layout
span 05

Shorthand

4 sub-props.

Cascade

❓ Frequently Asked Questions

grid-area places and sizes a grid item by setting where its row and column start and end, or by assigning it to a named area from grid-template-areas.
The default is auto for all four sides, which means the item is placed in the next available cell according to the grid auto-placement flow.
grid-template-areas defines named regions on the grid container. grid-area assigns an individual item to one of those named regions, or sets line numbers on the item itself.
The item starts at row line 2 and column line 1, then ends at row line 4 and column line 3. It spans two rows and two columns in that region.
Yes. You can use span syntax such as grid-area: 1 / 1 / span 2 / span 3 to stretch an item across multiple rows and columns from a starting line.

Practice in the Live Editor

Open the HTML editor, set grid-area with line numbers or names, and see how items span across the grid.

HTML Editor →

About the author

Mari Selvan M P
Mari Selvan M P 🔗

Developer, cloud engineer, and technical writer

  • Experience 12 years building web and cloud systems
  • Focus Full Stack Development, AWS, and Developer Education

I write practical tutorials so students and working developers can learn by doing—from databases and APIs to deployment on AWS.

5 people found this page helpful