📖 Scenario: You are building a simple website for a local bakery. The website needs a clear navigation menu so visitors can easily find important pages like Home, About, Menu, and Contact.
🎯 Goal: Create a basic navigation bar using semantic HTML elements. The navigation should have links to Home, About, Menu, and Contact pages.
📋 What You'll Learn
Use the <nav> element to wrap the navigation links.
Use an unordered list <ul> inside the <nav> for the menu items.
Each menu item should be a list item <li> containing a link <a>.
Links should have the exact text: Home, About, Menu, Contact.
Use semantic HTML5 elements and proper nesting.
💡 Why This Matters
🌍 Real World
Navigation menus are essential for websites to help users find information quickly and easily.
💼 Career
Understanding semantic HTML and accessibility is crucial for front-end web development roles.
Progress0 / 4 steps
1
Create the basic HTML skeleton
Write the basic HTML5 document structure with <!DOCTYPE html>, <html lang="en">, <head> with <meta charset="UTF-8"> and <title>Bakery Website</title>, and an empty <body>.
HTML
Hint
Start by typing the standard HTML5 document structure. Remember to include lang="en" in the <html> tag and set the charset to UTF-8.
2
Add the navigation container
Inside the <body>, add a <nav> element to hold the navigation menu.
HTML
Hint
Use the semantic <nav> tag to create a container for navigation links.
3
Add the unordered list with menu items
Inside the <nav>, add an unordered list <ul>. Inside the <ul>, add four list items <li> each containing a link <a> with the exact text: Home, About, Menu, Contact. Use href="#" for all links.
HTML
Hint
Remember to wrap each link inside a list item <li> and put all list items inside the <ul>.
4
Add accessibility with aria-label
Add an aria-label="Primary navigation" attribute to the <nav> element to improve accessibility for screen readers.
HTML
Hint
Use the aria-label attribute on the <nav> tag to describe the navigation purpose for screen readers.
Practice
(1/5)
1. What is the main purpose of the <nav> element in HTML?
easy
A. To define a section of navigation links
B. To add images to the page
C. To create a footer area
D. To style text with bold font
Solution
Step 1: Understand the role of <nav>
The <nav> element is designed to group navigation links on a webpage.
Step 2: Compare with other options
Options A, B, and D describe unrelated HTML functions like footers, images, or text styling.
Final Answer:
To define a section of navigation links -> Option A
Quick Check:
Navigation = <nav> section [OK]
Hint: Remember: <nav> groups navigation links only [OK]
Common Mistakes:
Confusing <nav> with <footer>
Thinking <nav> adds images
Using <nav> for styling text
2. Which of the following is the correct way to start a navigation section in HTML?
easy
A. <navigation>
B.
C. <nav>
D.
Solution
Step 1: Recall the correct HTML tag for navigation
The official HTML5 tag for navigation is <nav>.
Step 2: Check other options for validity
Tags like <navigation>, <nav-section>, and <nav-area> are not valid HTML tags.
Final Answer:
<nav> -> Option C
Quick Check:
Correct tag = <nav> [OK]
Hint: Use exactly <nav> to start navigation [OK]
Common Mistakes:
Using non-standard tags like <navigation>
Adding extra words in tag names
Confusing with other section tags
3. What will the following HTML code display in a browser?