Skip to content
Guest
Learn CSS · Course Syllabus Show lessons
Layout Systems · 9 min read · Beginner

Grid Template Areas & CSS Subgrid

Sketch entire page layouts visually with grid-template-areas and align nested card elements across columns using subgrid.

What you'll learn

  • Define readable page regions using grid-template-areas and grid-area
  • Align titles, descriptions, and footers across sibling cards with grid-template-rows: subgrid

Visual Page Blueprints with grid-template-areas

Instead of counting line numbers like grid-column: 1 / 3, you can draw your layout directly in CSS:

.page {
  display: grid;
  grid-template-areas:
    "header header"
    "sidebar main"
    "footer footer";
  grid-template-columns: 160px 1fr;
  gap: 10px;
}

Aligning Nested Cards with subgrid

Ever had a row of 3 cards where one card has a 2-line title and its button doesn’t line up with the neighbors? grid-template-rows: subgrid lets child cards inherit the parent grid’s row tracks so every heading, body, and footer aligns perfectly!

Fill-in-the-Blank Exercise

Named Grid Area & Subgrid

Assign the header element to the 'header' area and enable row subgrid on the card.

.top {
: header;
}
.card {
display: grid;
grid-row: span 3;
grid-template-rows: ;
}

Try It Yourself

Notice how all three cards keep their headings and buttons aligned even though the middle card has a longer title!

Aligned Card Row with CSS Subgrid
Live Result

Check Your Understanding

Score: 0 / 1

1. What problem does grid-template-rows: subgrid solve for a row of cards?

Study Workspace

Finished this lesson?

Your progress is saved locally in your browser, no account needed.

Search courses, lessons, and references

Type to search across all courses, lessons, and quick references.

Press Esc to close Powered by Pagefind