Discover how simple tags can make your website clear and friendly for everyone!
Why Header, footer, main in HTML? - Purpose & Use Cases
Imagine you are building a website by typing all the content in one big block without any structure. You write the title, then the menu, then the main content, and finally the copyright note all mixed together.
Without clear sections, it becomes hard to find and update parts like the menu or footer. The page looks messy in code, and screen readers or search engines struggle to understand the page layout.
Using <header>, <footer>, and <main> tags gives your page clear parts. This helps browsers, tools, and people know which part is the top, the main content, and the bottom.
<div>Title and menu here</div>
<div>Main content here</div>
<div>Footer info here</div><header>Title and menu here</header>
<main>Main content here</main>
<footer>Footer info here</footer>It makes your website easier to read, update, and accessible for everyone, including people using screen readers.
Think of a newspaper: the header is like the newspaper's name and date, the main is the articles, and the footer is the contact info and copyright. Using these tags is like organizing your page like a real newspaper.
Clear page sections improve code readability and maintenance.
Semantic tags help accessibility and SEO.
They create a natural structure like real-world documents.
Practice
Solution
Step 1: Understand the purpose of <main>
The <main> element is designed to hold the main content that is unique to the page, excluding repeated content like headers or footers.Step 2: Compare with other elements
<header> is for top parts like titles or menus, <footer> is for bottom parts like contact info, and <section> is a generic container but not specifically for main content.Final Answer:
<main> -> Option DQuick Check:
Main content = <main> [OK]
- Using <section> instead of <main> for main content
- Putting main content inside <header> or <footer>
- Confusing <main> with <article>
Solution
Step 1: Identify the correct HTML5 footer tag
The correct tag for footer content is <footer>. Tags like <foot>, <bottom>, and <end> do not exist in HTML5.Step 2: Confirm the syntax
The syntax <footer>...</footer> correctly wraps footer content.Final Answer:
<footer>Contact us at email@example.com</footer> -> Option BQuick Check:
Footer tag = <footer> [OK]
- Using non-existent tags like <foot> or <bottom>
- Misspelling the footer tag
- Using <div> without semantic meaning
<header>Site Title</header> <main>Welcome to our website</main> <footer>Contact info</footer>
Solution
Step 1: Understand semantic order of header, main, footer
The <header> appears first and is shown at the top, <main> is the main content in the middle, and <footer> is at the bottom.Step 2: Visualize the content placement
Content inside <header> shows "Site Title" at top, <main> shows "Welcome to our website" in the middle, and <footer> shows "Contact info" at the bottom.Final Answer:
Site Title at top, Welcome message in middle, Contact info at bottom -> Option AQuick Check:
Header top, main middle, footer bottom [OK]
- Assuming footer appears at top
- Confusing main content position
- Thinking order is random without CSS
<header>Welcome</header> <main>Content here</main> <footer>Footer info<footer>
Solution
Step 1: Check each tag for proper opening and closing
The <header> and <main> tags are correctly opened and closed. The <footer> tag is opened but closed incorrectly as <footer> instead of </footer>.Step 2: Identify the specific error
The footer closing tag is missing the slash, causing invalid HTML.Final Answer:
The closing tag for footer is incorrect -> Option CQuick Check:
Footer closing tag must be </footer> [OK]
- Forgetting slash in closing tags
- Confusing opening and closing tags
- Assuming missing tags instead of wrong closing
Solution
Step 1: Use semantic tags for each part
The header should contain the navigation menu inside <nav>. The main content should be inside <main> with an <article>. The footer should have copyright info inside <footer>.Step 2: Check each option for correct semantic structure
<header><nav>Menu</nav></header> <main><article>Article content</article></main> <footer>© 2024 Company</footer> uses correct semantic tags: <header><nav></nav></header>, <main><article></article></main>, and <footer>. Other options misuse tags or use generic <div> instead of semantic elements.Final Answer:
<header><nav>Menu</nav></header> <main><article>Article content</article></main> <footer>© 2024 Company</footer> -> Option AQuick Check:
Header-nav, main-article, footer correct semantic [OK]
- Using <div> instead of semantic tags
- Placing main content inside footer
- Nesting main inside article incorrectly
Ready to prove it?
Pass the test and this pattern moves unknown
