Holy Grail Layout
What You'll Learn
You'll learn how to create the classic "Holy Grail" layout—a header, footer, and three-column content area—using flexbox properties you already know.
What Is the Holy Grail Layout?
The "Holy Grail" is a legendary web layout pattern featuring a full-width header at the top, a full-width footer at the bottom, and three columns in the middle: a main content area flanked by two sidebars (navigation and extras). The challenge has always been making the three columns equal height while keeping the main content flexible.
Think of it like a newspaper: masthead across the top, footer information at the bottom, and three columns of content in between—all perfectly aligned.
Building It with Flexbox
First, create a flex container for the overall page structure using flex-direction: column to stack header, content area, and footer vertically. Then nest another flex container for the three-column section using flex-direction: row.
The outer container handles the vertical stacking (header → content → footer), while the inner container manages the horizontal three-column layout. Use flex-grow on the main content column so it claims leftover space, while the sidebars maintain fixed or flex-basis widths.
For equal-height columns, remember that flex items in a row automatically stretch to match the tallest item (thanks to the default align-items: stretch). The middle content section should use flex: 1 to fill available vertical space, pushing the footer to the bottom.
You can apply gap for spacing, justify-content for distribution, and order if you need the visual sequence to differ from the HTML source order (useful for accessibility—putting main content first in HTML but displaying navigation on the left).
Key Takeaway: The Holy Grail layout uses nested flex containers—one for vertical page structure (column) and one for horizontal content columns (row)—with flex-grow ensuring the main content fills available space while sidebars stay sized.