Bird
Raised Fist0
HTMLmarkup~20 mins

Header, footer, main in HTML - Practice Problems & Coding Challenges

Choose your learning style10 modes available
Challenge - 5 Problems
šŸŽ–ļø
Semantic Layout Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
ā“ rendering
intermediate
2:00remaining
What is the visual output of this HTML structure?
Consider this HTML code:
<header><h1>Welcome</h1></header>
<main><p>Main content here.</p></main>
<footer><p>Footer info</p></footer>

What will the browser display?
HTML
<header><h1>Welcome</h1></header>
<main><p>Main content here.</p></main>
<footer><p>Footer info</p></footer>
AOnly the footer paragraph 'Footer info' is visible.
BThe main content is hidden and only header and footer show.
CA page with a big heading 'Welcome' at top, a paragraph 'Main content here.' below it, and a footer paragraph 'Footer info' at the bottom.
DThe heading and footer are swapped in position visually.
Attempts:
2 left
šŸ’” Hint
Think about the natural order of header, main, and footer in HTML.
🧠 Conceptual
intermediate
1:30remaining
Which semantic element is best for the main content?
You want to mark the main part of your webpage that holds the primary information. Which HTML element should you use?
A<main>
B<footer>
C<header>
D<section>
Attempts:
2 left
šŸ’” Hint
The element should represent the main content unique to the page.
ā“ selector
advanced
1:30remaining
Which CSS selector targets only the footer element?
Given this HTML:
<header>...</header>
<main>...</main>
<footer>...</footer>

Which CSS selector will style only the footer?
Afooter
Bmain
Csection
Dheader
Attempts:
2 left
šŸ’” Hint
The selector matches the element name you want to style.
ā“ layout
advanced
2:30remaining
How to keep footer at bottom of viewport if content is short?
You want the footer to always appear at the bottom of the browser window even if the main content is small. Which CSS approach works best?
ASet footer display to inline-block;
BSet footer position to fixed with bottom: 0;
CUse float: right on footer.
DUse flexbox on body with column direction and main to grow, footer at bottom.
Attempts:
2 left
šŸ’” Hint
Think about a layout that stretches main content to fill space pushing footer down.
ā“ accessibility
expert
3:00remaining
Which ARIA role best describes the main content for screen readers?
You want to improve accessibility by explicitly marking the main content region for assistive technologies. Which ARIA role should you add to the <main> element?
Arole="banner"
Brole="main"
Crole="contentinfo"
Drole="navigation"
Attempts:
2 left
šŸ’” Hint
The role should match the main content landmark.

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