Complete the code to create a semantic header section.
<[1]>Welcome to my website</[1]>
The header tag is used to define the header of a page or section, making the structure clear to browsers and assistive technologies.
Complete the code to mark up the main content area semantically.
<[1]>This is the main content of the page.</[1]>
The main tag defines the main content of the document, which is unique and central to the page.
Fix the error in the code by choosing the correct semantic tag for a navigation menu.
<[1]> <ul> <li><a href="#home">Home</a></li> <li><a href="#about">About</a></li> </ul> </[1]>
The nav tag is the correct semantic element to wrap navigation links, helping screen readers and search engines understand the page structure.
Fill both blanks to create a semantic article with a footer.
<[1]> <h2>My Article</h2> <p>This is an article about semantic HTML.</p> <[2]> <p>Written by Jane Doe</p> </[2]> </[1]>
The article tag wraps the content that forms an independent piece of content, and the footer tag inside it contains information about the article like the author.
Fill all three blanks to create a semantic page layout with header, main, and footer.
<[1]> <h1>Site Title</h1> </[1]> <[2]> <p>Welcome to the homepage.</p> </[2]> <[3]> <p>Contact info here.</p> </[3]>
The header tag is for the top section, main for the main content, and footer for the bottom section of the page. This structure helps browsers and assistive tools understand the page layout.
Practice
Solution
Step 1: Understand semantic HTML purpose
Semantic HTML tags describe the role of content, making it easier to understand.Step 2: Identify the benefit for users and search engines
Meaningful tags help screen readers and search engines find and interpret content correctly.Final Answer:
It gives meaning to the structure, helping users and search engines understand content. -> Option CQuick Check:
Semantic HTML = Meaningful structure [OK]
- Thinking semantic tags affect page speed
- Believing semantic tags change styles automatically
- Assuming semantic tags hide content
Solution
Step 1: Recall semantic tags for main content
The<main>tag is designed to wrap the main content of a page.Step 2: Differentiate from other tags
<div>and<span>are generic containers without meaning;<footer>is for page footer.Final Answer:
<main> -> Option DQuick Check:
Main content tag = <main> [OK]
- Using <div> instead of semantic tags
- Confusing <footer> with main content
- Using <span> for block-level content
<header> <h1>Welcome to My Site</h1> </header>
Solution
Step 1: Understand screen reader behavior with semantic tags
Screen readers announce headings inside<header>as headings, helping users navigate.Step 2: Analyze the snippet content
The snippet has an<h1>inside<header>, so it reads "Heading level 1, Welcome to My Site".Final Answer:
"Heading level 1, Welcome to My Site" indicating page header -> Option AQuick Check:
Screen reader reads headings inside header correctly [OK]
- Thinking header acts like a button or link
- Assuming header hides content from screen readers
- Confusing header with images or links
<div> <nav>Main Navigation</nav> </div>
Solution
Step 1: Check semantic tag usage
The<nav>tag already defines navigation, so wrapping it in a generic<div>adds no meaning.Step 2: Understand impact on semantics
Extra<div>can confuse assistive technologies and developers by adding unnecessary layers.Final Answer:
Using <div> around <nav> is unnecessary and reduces semantic clarity. -> Option AQuick Check:
Unnecessary wrappers reduce semantic clarity [OK]
- Thinking nav cannot contain text
- Believing nav must be inside header
- Replacing div with section without reason
Solution
Step 1: Identify semantic tags for page parts
<header>is for site title,<nav>for menus,<main>for main content,<article>for posts, and<footer>for contact info.Step 2: Evaluate other options
The other options misuse tags or use non-semantic tags, harming accessibility and SEO.Final Answer:
<header> for site title, <nav> for menu, <main> for articles, <article> for each post, <footer> for contact info -> Option BQuick Check:
Correct semantic structure improves accessibility and SEO [OK]
- Using div or span instead of semantic tags
- Mixing up roles of header, main, article, footer
- Placing navigation inside non-semantic tags
Ready to prove it?
Pass the test and this pattern moves unknown
