Complete the code to create a semantic header section.
<[1]>Welcome to my website</[1]>
The header tag is a semantic element used to define the header of a page or section.
Complete the code to create a non-semantic container.
<[1]>This is a container without semantic meaning.</[1]>
The div tag is a non-semantic element used as a generic container.
Fix the error in the code by replacing the non-semantic tag with a semantic one for navigation.
<[1]>Home | About | Contact</[1]>
The nav tag is semantic and used specifically for navigation links.
Fill both blanks to create a semantic article with a footer.
<[1]> <h2>My Article</h2> <p>This is the content.</p> <[2]>Written by me</[2]> </[1]>
The article tag defines independent content, and footer defines the footer of that content.
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 main content area.</p> </[2]> <[3]> <p>Ā© 2024 My Website</p> </[3]>
The header contains introductory content, main holds the main page content, and footer contains footer information.
Practice
Solution
Step 1: Understand semantic elements
Semantic elements clearly describe their meaning, like<article>which represents an independent piece of content.Step 2: Identify non-semantic elements
<div>and<span>are generic containers without meaning.<b>is a presentational element without semantic meaning.Final Answer:
<article> -> Option AQuick Check:
Semantic element = <article> [OK]
- Confusing <div> as semantic
- Thinking <span> is semantic
- Thinking <b> is semantic
Solution
Step 1: Recognize semantic header tag
<header>is the semantic tag for page or section headers.Step 2: Differentiate from
<head><head>contains metadata, not visible content.<heading>is not a valid HTML tag.Final Answer:
<header>Welcome</header> -> Option CQuick Check:
Semantic header = <header> [OK]
- Using <head> for visible content
- Writing invalid <heading> tag
- Confusing metadata with page content
<div><h1>Title</h1><p>Paragraph</p></div>
Choose the best description.
Solution
Step 1: Understand
<div>usage<div>is a non-semantic container that can hold any flow content including headings and paragraphs.Step 2: Check rendering of heading and paragraph
The<h1>will display as a large bold heading, and<p>as a paragraph below it, both visible inside the container.Final Answer:
A heading 'Title' and a paragraph 'Paragraph' inside a generic container -> Option BQuick Check:
Non-semantic container shows all content [OK]
- Thinking div restricts content types
- Assuming heading is hidden
- Believing invalid nesting error occurs
<section><div>Content</section></div>
Solution
Step 1: Check tag nesting order
The<div>opens inside<section>but closes after</section>, breaking proper nesting.Step 2: Understand correct nesting rules
Tags must close in reverse order of opening. Here,<div>should close before</section>.Final Answer:
The <div> tag is not closed before </section> -> Option DQuick Check:
Proper nesting = close inner tags first [OK]
- Ignoring tag closing order
- Thinking div can't be inside section
- Missing closing tags
<div><div>Main content</div><div>Footer info</div></div>
Solution
Step 1: Identify semantic tags for main content and footer
<main>is the semantic tag for main page content, and<footer>is for footer information.Step 2: Replace non-semantic
Changing the outer<div>with semantic tags<div>to<main>and the footer<div>to<footer>improves meaning and accessibility.Final Answer:
Replace outer <div> with <main> and inner footer <div> with <footer> -> Option AQuick Check:
Use <main> and <footer> for better semantics [OK]
- Using <article> instead of <main> for main content
- Replacing all divs with <section> unnecessarily
- Ignoring semantic improvements
Ready to prove it?
Pass the test and this pattern moves unknown
