topskill.dev
CoursesTracks
0
All courses/CSSLantern Market navigation
Project - Dropdown Menu
1 / 3
← CSS
○CSS Rule Style an Exhibit Card○Write Your First CSS Rule○CSS Selectors Target Exhibit Details○Target Exhibit Details○Apply CSS Three Sources○Apply CSS Three Ways○Specificity Resolve a Style Conflict○Resolve Specificity○Inheritance and the cascade✦Module Quiz
○Color Palette○Color Palette○Background Layer○Background Layer○Type Rhythm○Type Rhythm○Borders and Shadows○Borders and Shadows✦Module Quiz
○Box Model Seed Packet Card○Space a Seed Packet○Display Swap Table Labels○Arrange Swap Table Labels○Positioning Pickup Pin○Pin the Pickup Location○Sizing and Overflow○Size a Seed-Swap Notice○Sticky scroll headings✦Module Quiz
○Advanced Selectors Book Cart Sign○Target a Book Cart Sign○Pseudo-Classes Night Cart States○Style Night Cart States○Pseudo-Elements○Add a Book-Quote Mark✦Module Quiz
●Lantern Market navigation○Lantern Market navigation✦Module Quiz
○Community garden request card○Community garden request card✦Module Quiz
○Flex Direction○Flex Direction○Main-Axis Spacing○Main-Axis Spacing○Cross-Axis Alignment○Cross-Axis Alignment○Wrapping and Flex Items○Wrapping and Flex Items○Flexbox Navigation○Flexbox Navigation✦Module Quiz
○Grid Tracks○Grid Tracks○Grid Gaps○Grid Gaps○Grid Placement○Grid Placement○Responsive Grid○Responsive Grid✦Module Quiz
○River radio schedule○Harbor radio schedule✦Module Quiz
○Field note color system○Field note color system○Transforms○Rotate a Field Note○Resilient styles✦Module Quiz
○Kite festival signal○Garden festival signal✦Module Quiz
○Garden forecast○Harbor forecast○Fluid sizing○Fluid weather bulletin○Images that fit✦Module Quiz
○Seed inventory table○Tool checkout table✦Module Quiz
○Community maker profile○Maker profile sheet✦Module Quiz

Lantern Market navigation

A dropdown with a native toggle

The directory has two stall links inside a native details element. Its summary, Stalls, is the control that opens and closes it. HTML already supplies the toggle behavior: click or tap the summary, or focus it and press Enter or Space. CSS only changes the presentation.

.menu-item[open] .submenu uses the attribute selector you learned earlier. The browser adds the boolean open attribute when details expands and removes it when it closes. There is no open="false" state: the attribute’s presence means open.

The base .submenu rule uses display: none; the more specific open-state rule changes it to block. The parent’s relative positioning anchors its absolute submenu, and top: 100% places it below the summary. A small z-index keeps the panel above the content that follows. This remains ordinary site navigation, not an ARIA menu with application-style arrow-key behavior.

Try the toggle and focus path

Run, open Stalls, and Tab through the two links. Shift+Tab moves back. The summary and links have visible focus outlines. Return to Stalls and press Space to close it. Moving focus or the pointer away does not close an open native disclosure; the visitor controls its state. Escape-to-close is not supplied here.

Change the submenu background in style.css, Run, and inspect the open panel. Restore #f7c948. A hover-only reveal would not give touch and keyboard users the same toggle. Elsewhere, :focus-within is useful for highlighting a field group while any descendant has focus; it is not needed to replace details’ native open state.

Hint 1
1 / 2
HINT 1

Keep the stylesheet linked from the document head.

HINT 2

Change one declaration at a time, then use Run Preview to inspect the result.

Files
  • ⋄index.html
  • ⋄style.css
Loading editor…