Course contentsShow
← Web Development
Lesson 358 of 2,9826. CSS GridFree lesson

Holy Grail Layout with Grid

Build the classic header-sidebar-content-footer layout using CSS Grid with minimal code.

What You'll Learn

You'll learn how to build the classic "Holy Grail" layout—header, two sidebars, content, and footer—with just a few lines of CSS Grid code.

The Holy Grail Layout with Grid

The Holy Grail Layout is a famous web design pattern with a full-width header at top, a full-width footer at bottom, and three columns in the middle (left sidebar, main content, right sidebar). Before Grid, achieving this required complex workarounds with floats or Flexbox.

With CSS Grid, you can create this layout elegantly using named grid areas.

The Classic Structure

Think of the Holy Grail like a newspaper: masthead across the top, two thin ad columns on the sides, the main article in the center, and copyright info across the bottom. Grid lets you paint this picture directly in CSS.

The Grid Solution

.container {
  display: grid;
  grid-template-columns: 200px 1fr 200px;
  grid-template-rows: auto 1fr auto;
  grid-template-areas:
    "header header header"
    "sidebar content aside"
    "footer footer footer";
  min-height: 100vh;
}

header { grid-area: header; }
.sidebar { grid-area: sidebar; }
main { grid-area: content; }
aside { grid-area: aside; }
footer { grid-area: footer; }

The grid-template-areas property creates a visual map of your layout. The header and footer span all three columns by repeating their names. The middle row splits into three distinct areas. Each element claims its named area with grid-area.

The 1fr in the middle column makes the content area flexible, while the sidebars stay at 200px. The middle row uses 1fr to push the footer down.

Key Takeaway: CSS Grid's named areas turn the Holy Grail layout from a CSS puzzle into a simple, readable template that matches how you visualize the design.