HTML & CSS - Mastery / CSS Grid System

Grid Template Areas (Part 1)

🎯 What is grid-template-areas?

grid-template-areas lets you name parts of your layout and place them using a text-based visual format. It's easier to read and maintain than using grid line numbers.


🔧 Syntax

grid-template-areas:
  "header header"
  "sidebar main"
  "footer footer";

Then apply it like:

.header  { grid-area: header; }
.sidebar { grid-area: sidebar; }
.footer { grid-area: footer; }

👨‍💻 Quick Example


✅ Benefits

  • Makes layout easier to read

  • Ideal for templates or page sections

  • Helpful in responsive design


⚠️ Tips

  • Use . for empty cells: "sidebar ."

  • All rows must have same number of names

  • Area names = valid CSS identifiers (no spaces)