📖 Scenario: You are building a classic web page layout called the Holy Grail Layout. This layout has a header at the top, a footer at the bottom, and three columns in the middle: a left sidebar, a main content area, and a right sidebar.Using Bootstrap's grid system and utility classes, you will create this layout so it looks good on desktop and stacks nicely on smaller screens.
🎯 Goal: Create a responsive Holy Grail layout using Bootstrap 5. The page should have:A header spanning full width at the topA footer spanning full width at the bottomA main section with three columns: left sidebar, main content, right sidebarThe sidebars should be narrower than the main contentOn small screens, the columns stack vertically
📋 What You'll Learn
Use Bootstrap 5 grid classes for layout
Create semantic HTML structure with , ,
Make the layout responsive so columns stack on small screens
Use Bootstrap container and row classes properly
Add distinct background colors to each section for clarity
💡 Why This Matters
🌍 Real World
The Holy Grail layout is a classic web page structure used in many websites to organize content clearly and accessibly.
💼 Career
Understanding how to build responsive layouts with Bootstrap is a key skill for front-end web developers and UI designers.
Progress0 / 4 steps
1
Create the basic HTML skeleton with Bootstrap
Create a basic HTML5 page with lang="en" and charset="UTF-8". Add the Bootstrap 5 CSS CDN link inside the <head>. Inside the <body>, add a <div> with class container to hold the page content.
Bootsrap
Hint
Remember to include the Bootstrap CSS link inside the <head> and create a div with class container inside the body.
2
Add the header and footer sections
Inside the div with class container, add a <header> with class bg-primary text-white p-3 containing the text Header. Also add a <footer> with class bg-dark text-white p-3 mt-3 containing the text Footer.
Bootsrap
Hint
Use Bootstrap background and text color classes for the header and footer. Add padding with p-3 and margin top mt-3 for the footer.
3
Add the main content area with three columns
Between the <header> and <footer>, add a <main> element with class row mt-3. Inside it, create three columns using Bootstrap grid classes: a left sidebar with class col-md-3 bg-light p-3 containing the text Left Sidebar, a main content area with class col-md-6 bg-white p-3 containing the text Main Content, and a right sidebar with class col-md-3 bg-light p-3 containing the text Right Sidebar. This will create three columns on medium and larger screens and stack them on smaller screens.
Bootsrap
Hint
Use Bootstrap's grid classes inside a row to create three columns. Use col-md-3 for sidebars and col-md-6 for main content. Add background colors and padding for clarity.
4
Make the layout responsive and accessible
Add aria-label attributes to the <aside> elements: aria-label="Left Sidebar" and aria-label="Right Sidebar". Also add role="main" to the <main> element. Finally, add a meta viewport tag inside the <head> with content width=device-width, initial-scale=1 to ensure proper scaling on mobile devices.
Bootsrap
Hint
Accessibility helps screen readers understand page structure. Add aria-label to sidebars and role="main" to the main content. The viewport meta tag ensures the page scales well on phones.
Practice
(1/5)
1. What is the main purpose of the Holy Grail layout in web design?
easy
A. To create a single column layout for mobile devices
B. To organize a page into header, footer, and three columns in the middle
C. To add animations to buttons and links
D. To style text with different fonts and colors
Solution
Step 1: Understand layout structure
The Holy Grail layout divides the page into a header, footer, and three columns in the middle.
Step 2: Identify the purpose
This layout helps organize content clearly and is common in web design.
Final Answer:
To organize a page into header, footer, and three columns in the middle -> Option B
C. The total column widths exceed 12 units, causing layout issues
D. The columns should use 'col-md-' instead of 'col-'
Solution
Step 1: Calculate total column units
col-3 + col-6 + col-4 = 3 + 6 + 4 = 13 units, which is more than 12.
Step 2: Understand Bootstrap grid limits
Bootstrap grid rows can only hold 12 units total; exceeding causes wrapping or broken layout.
Final Answer:
The total column widths exceed 12 units, causing layout issues -> Option C
Quick Check:
Sum of col-* > 12 breaks layout [OK]
Hint: Sum col-* classes must be 12 or less per row [OK]
Common Mistakes:
Ignoring total column width sum
Confusing container and row classes
Thinking 'col-' is invalid syntax
5. You want a Holy Grail layout with a header, footer, and three columns in the middle using Bootstrap. The left and right columns should be narrow on desktop but stack vertically on small screens. Which Bootstrap classes combination achieves this?