Bird
Raised Fist0
HTMLmarkup~20 mins

Nav element in HTML - Practice Problems & Coding Challenges

Choose your learning style10 modes available
Challenge - 5 Problems
🎖️
Nav Element Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
🧠 Conceptual
intermediate
1:30remaining
Purpose of the
What is the main purpose of the
ATo add a footer section at the bottom of the page.
BTo create a container for images and multimedia content.
CTo define a section containing navigation links for the website.
DTo style text with bold and italic effects.
Attempts:
2 left
💡 Hint
Think about what users use to move between pages on a website.
📝 Syntax
intermediate
2:00remaining
Correct Usage of
Which of the following HTML snippets correctly uses the
A<nav><p>Home</p><p>About</p></nav>
B<nav><span>Home</span><span>About</span></nav>
C<nav><div>Home</div><div>About</div></nav>
D<nav><ul><li><a href="home.html">Home</a></li><li><a href="about.html">About</a></li></ul></nav>
Attempts:
2 left
💡 Hint
Navigation links should be clickable and grouped in a list.
❓ rendering
advanced
2:00remaining
Visual Result of a
What will you see in the browser when this HTML and CSS code runs?
HTML
<nav style="display:flex; gap:1rem;"><a href="#">Home</a><a href="#">Services</a><a href="#">Contact</a></nav>
ALinks arranged randomly with overlapping text.
BThree links arranged horizontally with space between them.
CLinks hidden because <nav> cannot use flexbox.
DThree links stacked vertically with no space.
Attempts:
2 left
💡 Hint
Flexbox with display:flex arranges children in a row by default.
❓ accessibility
advanced
1:30remaining
Improving Accessibility of a
Which attribute improves accessibility by describing the purpose of a
Aaria-label="Main navigation"
Bstyle="color:blue"
Conclick="alert('nav clicked')"
Did="nav1"
Attempts:
2 left
💡 Hint
Screen readers use ARIA attributes to understand page sections.
B.
C.
D.

Solution

  1. Step 1: Check the element name

    The correct HTML element for navigation is <nav>, not <navigation>.
  2. Step 2: Verify proper structure for links

    Navigation links are best inside a list (<ul> with <li> and <a> tags) for semantics and accessibility.
  3. Final Answer:

    <nav><ul><li><a href='#'>Home</a></li></ul></nav> -> Option A
  4. Quick Check:

    Correct tag + list of links = <nav><ul><li><a href='#'>Home</a></li></ul></nav> [OK]
Hint: Use <nav> with <ul> and <li> for menus [OK]
Common Mistakes:
  • Using <navigation> instead of <nav>
  • Putting plain text instead of links inside <nav>
  • Not using list elements for navigation links
3. What will be the visual result of this HTML code in a browser?
<nav>
  <ul>
    <li><a href='#home'>Home</a></li>
    <li><a href='#about'>About</a></li>
  </ul>
</nav>
medium
A. Two paragraphs with 'Home' and 'About' text
B. A horizontal menu with buttons labeled 'Home' and 'About'
C. An error message because <nav> cannot contain <ul>
D. A vertical list of clickable links labeled 'Home' and 'About'

Solution

  1. Step 1: Understand default <ul> and <li> display

    By default, <ul> creates a vertical list with bullet points, and <li> items stack vertically.
  2. Step 2: Check the <a> tags inside list items

    The <a> tags create clickable links labeled 'Home' and 'About'.
  3. Final Answer:

    A vertical list of clickable links labeled 'Home' and 'About' -> Option D
  4. Quick Check:

    Default list + links = vertical clickable list [OK]
Hint: Lists inside <nav> show vertical clickable menus by default [OK]
Common Mistakes:
  • Assuming <nav> changes list layout automatically
  • Thinking <nav> causes errors with <ul>
  • Expecting horizontal menu without CSS
4. Identify the error in this navigation code:
<nav>
  <ul>
    <li>Home</li>
    <li><a href='#about'>About</a></li>
  </ul>
</nav>
medium
A. The first list item 'Home' is missing a link (<a> tag)
B. The <nav> element cannot contain <ul>
C. The <li> tags are not allowed inside <nav>
D. The href attribute is missing in the second link

Solution

  1. Step 1: Check each list item content

    The first <li> contains plain text 'Home' without a clickable link.
  2. Step 2: Confirm proper link usage

    Navigation items should be links (<a> tags) for accessibility and functionality.
  3. Final Answer:

    The first list item 'Home' is missing a link (<a> tag) -> Option A
  4. Quick Check:

    All nav items need <a> tags [OK]
Hint: Every nav item should be a link inside <li> [OK]
Common Mistakes:
  • Leaving text without <a> inside <li>
  • Thinking <nav> disallows <ul> or <li>
  • Ignoring missing href attributes
5. You want to create a navigation menu inside a website header that is accessible and clearly identified by screen readers. Which is the best way to use the <nav> element?
hard
A. <header>   <nav aria-label='Main navigation'>     <ul>       <li><a href='/home'>Home</a></li>       <li><a href='/contact'>Contact</a></li>     </ul>   </nav> </header>
C.
D.

Solution

  1. Step 1: Use <nav> inside <header> for main navigation

    Placing <nav> inside <header> groups navigation logically.
  2. Step 2: Add aria-label for accessibility

    The aria-label 'Main navigation' helps screen readers identify this menu clearly.
  3. Step 3: Use list with links inside <nav>

    Using <ul> and <li> with <a> tags creates a semantic, accessible menu.
  4. Final Answer:

    Use <nav> with aria-label and list of links inside header -> Option B
  5. Quick Check:

    Accessible nav with aria-label = <header>   <nav aria-label='Main navigation'>     <ul>       <li><a href='/home'>Home</a></li>       <li><a href='/contact'>Contact</a></li>     </ul>   </nav> </header> [OK]
Hint: Add aria-label to <nav> for screen reader clarity [OK]
Common Mistakes:
  • Not using <a> tags for navigation items
  • Omitting aria-label for accessibility
  • Using plain text instead of links inside <nav>
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