0
0
HTMLmarkup~20 mins

Nested lists in HTML - Practice Problems & Coding Challenges

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
Nested Lists 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 nested list?
Look at the HTML code below. What will you see rendered in the browser?
HTML
<ul>
  <li>Fruit
    <ul>
      <li>Apple</li>
      <li>Banana</li>
    </ul>
  </li>
  <li>Vegetables
    <ul>
      <li>Carrot</li>
      <li>Broccoli</li>
    </ul>
  </li>
</ul>
AOnly Fruit and Vegetables appear as bullets; Apple, Banana, Carrot, Broccoli do not appear.
BA bulleted list with Fruit, Apple, Banana, Vegetables, Carrot, Broccoli all at the same level with no indentation.
CA bulleted list with two main items: Fruit and Vegetables. Under Fruit, Apple and Banana appear as indented bullets. Under Vegetables, Carrot and Broccoli appear as indented bullets.
DA numbered list with Fruit and Vegetables as main items, and Apple, Banana, Carrot, Broccoli as sub-items with numbers.
Attempts:
2 left
💡 Hint
Nested
    inside
  • creates sub-bullets.
selector
intermediate
2:00remaining
Which CSS selector targets only the nested list items?
Given this HTML structure with nested lists, which CSS selector will style only the inner list items (like Apple, Banana, Carrot, Broccoli)?
HTML
<ul>
  <li>Fruit
    <ul>
      <li>Apple</li>
      <li>Banana</li>
    </ul>
  </li>
  <li>Vegetables
    <ul>
      <li>Carrot</li>
      <li>Broccoli</li>
    </ul>
  </li>
</ul>
Aul li ul li
Bul > li
Cli ul
Dul li
Attempts:
2 left
💡 Hint
Think about selecting list items inside another list inside list items.
🧠 Conceptual
advanced
1:30remaining
Why use nested lists in HTML?
Which is the best reason to use nested lists in a webpage?
ATo show a hierarchy or grouping of related items clearly.
BTo make the page load faster by reducing HTML code.
CTo replace paragraphs with bullet points for all text.
DTo avoid using headings and paragraphs altogether.
Attempts:
2 left
💡 Hint
Think about how nested lists help organize information.
accessibility
advanced
1:30remaining
How to improve accessibility of nested lists?
Which practice improves accessibility for nested lists in HTML?
AReplace nested lists with images to show hierarchy visually.
BUse semantic tags like <ul> and <li> and ensure proper nesting without skipping levels.
CUse only <div> tags with CSS for all lists to control style.
DAdd multiple <br> tags between list items for spacing.
Attempts:
2 left
💡 Hint
Think about screen readers and semantic meaning.
layout
expert
2:30remaining
How to create a horizontal nested list menu with CSS?
You want a horizontal main menu with vertical dropdown submenus using nested lists. Which CSS snippet correctly achieves this layout?
HTML
<nav>
  <ul class="menu">
    <li>Home</li>
    <li>Services
      <ul class="submenu">
        <li>Design</li>
        <li>Development</li>
      </ul>
    </li>
    <li>Contact</li>
  </ul>
</nav>
A.menu li { float: left; } .submenu { float: right; }
B.menu { display: block; } .submenu { display: flex; flex-direction: row; }
C.menu { display: grid; grid-template-columns: 1fr 1fr 1fr; } .submenu { display: grid; grid-template-rows: 1fr 1fr; }
D.menu { display: flex; list-style: none; } .submenu { display: none; position: absolute; } .menu li:hover > .submenu { display: block; }
Attempts:
2 left
💡 Hint
Use flexbox for horizontal main menu and hide/show submenu on hover.