Build a responsive navigation menu
Implement one semantic navigation that expands inline on desktop and toggles accessibly on mobile.Description
Requirements
Navigation landmarks works deterministically for the documented normal, boundary, and repeated-use scenarios.
Toggle semantics works deterministically for the documented normal, boundary, and repeated-use scenarios.
Mobile open close works deterministically for the documented normal, boundary, and repeated-use scenarios.
Escape restores focus works deterministically for the documented normal, boundary, and repeated-use scenarios.
Link keyboard access works deterministically for the documented normal, boundary, and repeated-use scenarios.
Desktop layout works deterministically for the documented normal, boundary, and repeated-use scenarios.
Content remains inside the viewport without unintended horizontal scrolling at every reference width.
Mobile dismissal
Open the mobile menu and press Escape
The links collapse and keyboard focus returns to Menu
Desktop mode continues to show the same links without requiring the toggle.
Constraints
Use a nav landmark and a list of linksThe mobile toggle must be a native buttonKeep all links in the DOM in both layouts
Hints
Hint 1
Let one expanded state drive both visibility and aria-expanded.
Hint 2
Use a media query to establish desktop visibility rather than duplicating navigation markup.
Hint 3
When Escape closes the mobile menu, explicitly return focus to its toggle.