Bird
Raised Fist0
HTMLmarkup~15 mins

Header, footer, main in HTML - Deep Dive

Choose your learning style10 modes available
Overview - Header, footer, main
What is it?
Header, footer, and main are special parts of a webpage that organize content clearly. The header usually holds the title or navigation links at the top. The footer sits at the bottom with extra info like contact or copyright. The main area is where the main content lives, like articles or images.
Why it matters
Without these parts, webpages would be messy and confusing. They help people find important info quickly and make websites easier to read and use. They also help computers and tools understand the page structure, improving accessibility and search results.
Where it fits
Before learning these, you should know basic HTML tags like div and p. After this, you can learn about layout with CSS and how to make pages interactive with JavaScript.
Mental Model
Core Idea
Header, footer, and main divide a webpage into clear sections for top, bottom, and main content, making structure and meaning obvious.
Think of it like...
Think of a webpage like a book: the header is the cover and table of contents, the main is the story inside, and the footer is the back cover with extra notes.
┌─────────────── Header ───────────────┐
│ Navigation, logo, page title         │
├─────────────── Main ────────────────┤
│ Main content: articles, images, text │
├─────────────── Footer ───────────────┤
│ Contact info, copyright, links       │
└──────────────────────────────────────┘
Build-Up - 7 Steps
1
FoundationUnderstanding semantic HTML basics
🤔
Concept: Learn what semantic HTML means and why it matters.
Semantic HTML uses tags that describe their meaning, like
,
, and
, instead of generic
tags. This helps browsers and people understand the page better.
Result
You can write HTML that clearly shows the purpose of each part of your page.
Understanding semantic tags is the first step to building accessible and well-structured webpages.
2
FoundationIntroducing header, footer, and main tags
🤔
Concept: Meet the three main semantic tags for page layout.
The
tag holds the top part of the page, like logos or menus. The
tag holds the bottom part, like contact info. The
tag holds the main content unique to that page.
Result
You can now separate your page into meaningful sections using these tags.
Knowing these tags helps you organize content logically and improves page clarity.
3
IntermediateUsing header for navigation and branding
🤔Before reading on: do you think the header should only contain the page title or also navigation links? Commit to your answer.
Concept: The header often includes navigation menus and branding elements, not just titles.
Inside
, you can put a logo image, the site name, and navigation links using
Result
Your page header becomes a helpful guide for visitors to explore your site.
Understanding the header's role beyond just a title improves user experience and site navigation.
4
IntermediateFooter for extra info and links
🤔Before reading on: do you think footer content is visible on every page or only on the homepage? Commit to your answer.
Concept: Footers usually contain information repeated across pages, like contact details or legal links.
Use
to add copyright notices, privacy policies, or social media links. This section appears at the bottom and helps users find important info easily.
Result
Your footer provides consistent, useful info on every page.
Knowing footer's role helps you keep important info accessible without cluttering main content.
5
IntermediateMain tag for unique page content
🤔
Concept: The
tag holds the main content that changes from page to page.
Place articles, blog posts, images, or forms inside
. This tells browsers and assistive tools where the main focus is.
Result
Your page clearly shows what content is most important.
Using
correctly improves accessibility and helps search engines understand your page.
6
AdvancedAccessibility benefits of semantic sections
🤔Before reading on: do you think screen readers rely on semantic tags to navigate pages? Commit to your answer.
Concept: Semantic tags help assistive technologies like screen readers navigate and understand pages better.
Screen readers can jump directly to
or
Result
Your site becomes more inclusive and user-friendly for everyone.
Understanding accessibility benefits motivates using semantic tags properly, not just for visuals.
7
ExpertCommon pitfalls and SEO impact
🤔Before reading on: do you think missing semantic tags can hurt your site's search ranking? Commit to your answer.
Concept: Search engines use semantic tags to understand page structure and content importance.
If you skip
or misuse
and
, search engines may misinterpret your page, lowering SEO. Also, improper nesting or multiple
tags can confuse browsers and tools.
Result
Proper use of these tags improves SEO and page clarity.
Knowing how semantic tags affect SEO and browser behavior helps avoid subtle bugs and boosts site visibility.
Under the Hood
Browsers parse HTML and build a document tree. Semantic tags like
,
, and
label parts of this tree with meaning. Assistive technologies read these labels to help users navigate. Search engines analyze them to rank content relevance.
Why designed this way?
Semantic tags were introduced to replace generic containers like
with meaningful elements. This improves accessibility, SEO, and code clarity. Before, pages were just blocks without meaning, making navigation and indexing harder.
HTML Document
┌─────────────────────────────┐
│ <html>                     │
│  ├─ <body>                 │
│  │   ├─ <header>           │
│  │   ├─ <main>             │
│  │   └─ <footer>           │
│  └─────────────────────────┘
└─────────────────────────────┘

Assistive Tech & Search Engines
  ↓
Use semantic tags to identify page sections
Myth Busters - 4 Common Misconceptions
Quick: Is it okay to have multiple
tags on one page? Commit to yes or no.
Common Belief:You can use multiple
tags if you want to highlight several main areas.
Tap to reveal reality
Reality:Only one
tag should exist per page to mark the primary content area.
Why it matters:Using multiple
tags confuses browsers and assistive tools, harming accessibility and SEO.
Quick: Does the
tag only belong at the top of the whole page? Commit to yes or no.
Common Belief:
is only for the top of the entire webpage.
Tap to reveal reality
Reality:
can appear inside sections or articles to label their headings, not just at the page top.
Why it matters:Misunderstanding this limits flexible, semantic page structure and can reduce clarity.
Quick: Does skipping semantic tags have no effect on SEO? Commit to yes or no.
Common Belief:Search engines don’t care about semantic tags; they only read text.
Tap to reveal reality
Reality:Semantic tags help search engines understand page layout and content importance, affecting ranking.
Why it matters:Ignoring semantic tags can lower your site’s visibility in search results.
Quick: Can you use
inside an article? Commit to yes or no.
Common Belief:
is only for the bottom of the whole page.
Tap to reveal reality
Reality:
can be used inside articles or sections to hold related info like author or references.
Why it matters:Knowing this allows richer, more meaningful page structures.
Expert Zone
1
Some screen readers allow users to jump between
,
, and
quickly, so proper use improves navigation speed.
2
Using
and
inside nested sections or articles creates a clear hierarchy that benefits both humans and machines.
3
Browsers apply default styling to these tags, but it’s minimal; developers often customize them with CSS for better design.
When NOT to use
Avoid using
inside components that are repeated multiple times on a page, like cards or widgets; use
or
instead. For very simple pages, semantic tags might be overkill, but accessibility should still be considered.
Production Patterns
In professional sites,
often contains responsive navigation menus with hamburger icons. Footers include sitemap links and legal disclaimers.
is dynamically updated with content fetched from servers or APIs.
Connections
ARIA landmarks
Builds-on
Understanding semantic tags helps grasp ARIA landmarks, which provide extra accessibility hints for screen readers.
Document Object Model (DOM)
Same pattern
Semantic tags form part of the DOM tree structure, so knowing them improves your ability to manipulate page content with JavaScript.
Book publishing layout
Similar structure
Recognizing how webpages mirror book layouts (cover, content, back cover) helps understand why these tags exist and how they improve reading flow.
Common Pitfalls
#1Using multiple
tags on one page.
Wrong approach:
First main content
Second main content
Correct approach:
All main content combined here
Root cause:Misunderstanding that
should be unique per page.
#2Putting navigation links outside
or
Wrong approach:
Correct approach:
Root cause:Not knowing semantic tags improve meaning and accessibility.
#3Using
only for copyright, ignoring other info.
Wrong approach:
© 2024
Correct approach:
© 2024 | Contact: email@example.com | Privacy Policy
Root cause:Underestimating footer’s role in providing useful site-wide info.
Key Takeaways
Header, footer, and main tags give your webpage a clear, meaningful structure that helps users and machines.
Using these semantic tags improves accessibility for people using screen readers and boosts search engine understanding.
Only one
tag should exist per page, while header and footer can appear multiple times inside sections.
Headers often contain navigation and branding, footers hold extra info, and main holds the unique page content.
Proper use of these tags prevents confusion, improves SEO, and creates a better experience for all visitors.

Practice

(1/5)
1. Which HTML element is best used to contain the main content unique to a webpage?
easy
A. <section>
B. <header>
C. <footer>
D. <main>

Solution

  1. 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.
  2. 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.
  3. Final Answer:

    <main> -> Option D
  4. Quick Check:

    Main content = <main> [OK]
Hint: Main content always goes inside <main> tag [OK]
Common Mistakes:
  • Using <section> instead of <main> for main content
  • Putting main content inside <header> or <footer>
  • Confusing <main> with <article>
2. Which of the following is the correct syntax to create a footer section in HTML5?
easy
A. Contact us at email@example.com
B.
Contact us at email@example.com
C. Contact us at email@example.com
D. Contact us at email@example.com

Solution

  1. 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.
  2. Step 2: Confirm the syntax

    The syntax <footer>...</footer> correctly wraps footer content.
  3. Final Answer:

    <footer>Contact us at email@example.com</footer> -> Option B
  4. Quick Check:

    Footer tag = <footer> [OK]
Hint: Footer tag is exactly <footer> in HTML5 [OK]
Common Mistakes:
  • Using non-existent tags like <foot> or <bottom>
  • Misspelling the footer tag
  • Using <div> without semantic meaning
3. What will be the visual order of content in the browser for this HTML snippet?
<header>Site Title</header>
<main>Welcome to our website</main>
<footer>Contact info</footer>
medium
A. Site Title at top, Welcome message in middle, Contact info at bottom
B. Contact info at top, Site Title in middle, Welcome message at bottom
C. Welcome message at top, Contact info in middle, Site Title at bottom
D. All content mixed randomly

Solution

  1. 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.
  2. 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.
  3. Final Answer:

    Site Title at top, Welcome message in middle, Contact info at bottom -> Option A
  4. Quick Check:

    Header top, main middle, footer bottom [OK]
Hint: Header top, main center, footer bottom visually [OK]
Common Mistakes:
  • Assuming footer appears at top
  • Confusing main content position
  • Thinking order is random without CSS
4. Identify the error in this HTML snippet:
<header>Welcome</header>
<main>Content here</main>
<footer>Footer info<footer>
medium
A. The header tag is not closed
B. The main tag is missing
C. The closing tag for footer is incorrect
D. There is no footer tag

Solution

  1. 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>.
  2. Step 2: Identify the specific error

    The footer closing tag is missing the slash, causing invalid HTML.
  3. Final Answer:

    The closing tag for footer is incorrect -> Option C
  4. Quick Check:

    Footer closing tag must be </footer> [OK]
Hint: Closing tags need a slash, e.g. [OK]
Common Mistakes:
  • Forgetting slash in closing tags
  • Confusing opening and closing tags
  • Assuming missing tags instead of wrong closing
5. You want to create a webpage with a header containing a navigation menu, a main section with an article, and a footer with copyright info. Which is the best semantic HTML structure?
hard
A.
Article content
© 2024 Company
B.
Article content
© 2024 Company
C.
Menu
© 2024 Company
Article content
D.
Article content
© 2024 Company

Solution

  1. 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>.
  2. 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.
  3. Final Answer:

    <header><nav>Menu</nav></header> <main><article>Article content</article></main> <footer>© 2024 Company</footer> -> Option A
  4. Quick Check:

    Header-nav, main-article, footer correct semantic [OK]
Hint: Use header-nav, main-article, footer for semantic clarity [OK]
Common Mistakes:
  • Using <div> instead of semantic tags
  • Placing main content inside footer
  • Nesting main inside article incorrectly
Recommended

Ready to prove it?

Pass the test and this pattern moves unknown strong while earning +1 Grip toward your certificate.

10 questions~5 mineasy hard