0
0
Tailwindmarkup~20 mins

Navigation bar patterns in Tailwind - Practice Problems & Coding Challenges

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
Navigation Bar Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
layout
intermediate
2:00remaining
Responsive Navigation Bar Layout
Which option correctly creates a responsive navigation bar that stacks links vertically on small screens and horizontally on larger screens using Tailwind CSS?
A<nav class="flex flex-col md:flex-row gap-4"><a href="#" class="text-blue-600">Home</a><a href="#" class="text-blue-600">About</a><a href="#" class="text-blue-600">Contact</a></nav>
B<nav class="flex-row flex md:flex-col gap-4"><a href="#" class="text-blue-600">Home</a><a href="#" class="text-blue-600">About</a><a href="#" class="text-blue-600">Contact</a></nav>
C<nav class="flex flex-row md:flex-col gap-4"><a href="#" class="text-blue-600">Home</a><a href="#" class="text-blue-600">About</a><a href="#" class="text-blue-600">Contact</a></nav>
D<nav class="flex-col flex md:flex-row gap-4"><a href="#" class="text-blue-600">Home</a><a href="#" class="text-blue-600">About</a><a href="#" class="text-blue-600">Contact</a></nav>
Attempts:
2 left
💡 Hint
Think about the default flex direction on small screens and how it changes on medium screens.
accessibility
intermediate
2:00remaining
Accessible Navigation Bar ARIA Roles
Which option correctly adds ARIA roles to a navigation bar for better accessibility?
A<nav aria-role="navigation" aria-label="Main menu"><ul><li><a href="#">Home</a></li><li><a href="#">Services</a></li><li><a href="#">Contact</a></li></ul></nav>
B<nav role="nav" aria-label="Main menu"><ul><li><a href="#">Home</a></li><li><a href="#">Services</a></li><li><a href="#">Contact</a></li></ul></nav>
C<nav role="navigation" aria-label="Main menu"><ul><li><a href="#">Home</a></li><li><a href="#">Services</a></li><li><a href="#">Contact</a></li></ul></nav>
D<nav role="navigation" aria-labelledby="menu"><ul><li><a href="#">Home</a></li><li><a href="#">Services</a></li><li><a href="#">Contact</a></li></ul></nav>
Attempts:
2 left
💡 Hint
ARIA roles must be spelled exactly and used properly to help screen readers.
selector
advanced
2:00remaining
Tailwind CSS Selector Specificity
Given this HTML snippet, which Tailwind CSS class combination will style only the active navigation link with a blue underline?
Tailwind
<nav><a href="#" class="nav-link active">Home</a><a href="#" class="nav-link">About</a><a href="#" class="nav-link">Contact</a></nav>
A.nav-link.active { @apply border-b-2 border-blue-600; }
B.nav-link .active { @apply border-b-2 border-blue-600; }
C.active.nav-link { @apply border-b-2 border-blue-600; }
D.nav-link > .active { @apply border-b-2 border-blue-600; }
Attempts:
2 left
💡 Hint
Remember how CSS selectors target elements by class names and their relationship.
🧠 Conceptual
advanced
2:00remaining
Keyboard Navigation in Navigation Bars
Which option best describes how to ensure keyboard users can navigate a multi-level navigation bar effectively?
AUse <span> elements with click handlers and no focus styles for dropdown toggles.
BUse only <div> elements for all navigation items and rely on mouse hover for dropdowns.
CDisable keyboard focus on dropdown menus to prevent confusion.
DUse <button> elements for dropdown toggles, manage focus with JavaScript, and ensure visible focus styles on links.
Attempts:
2 left
💡 Hint
Think about how keyboard users interact and what elements support focus and activation.
rendering
expert
2:00remaining
Tailwind CSS Sticky Navigation Bar with Shadow
Which option produces a sticky navigation bar at the top of the page with a subtle shadow that appears only when the user scrolls down?
A<nav class="sticky top-0 bg-white shadow-md">...</nav>
B<nav class="sticky top-0 bg-white">...</nav>
C<nav class="sticky top-0 bg-white shadow-md opacity-0">...</nav>
D<nav class="fixed top-0 bg-white shadow-md">...</nav>
Attempts:
2 left
💡 Hint
Sticky keeps the nav at top but shadow should appear only on scroll, so initial shadow class is not added.