Dropdown styling should support both pointer and keyboard use. CSS-only hover dropdowns are often inaccessible.
Safe dropdown styling goals
- Visible focus and hover states.
- Sufficient contrast on menu and items.
- Positioning that avoids clipping behind containers.
Pitfall
Menus triggered only on :hover fail touch and keyboard users; pair with JS state and ARIA semantics.
Important interview questions and answers
- Q: Why is pure hover dropdown problematic?
A: No reliable keyboard/touch interaction and often missing state announcements. - Q: Typical dropdown layering issue?
A: Clipping/overlap from overflow or z-index stacking contexts. - Q: What CSS improves menu readability?
A: Clear item spacing, hover/focus backgrounds, and shadow/border separation.
Pitfall: Check cascade order—author stylesheet loses to inline styles and !important surprises.