.menu > .item:nth-child(n+2) {
display: none;
}
.menu:hover > .item,
.menu:focus > .item,
.menu > .item:focus,
.item:focus ~ .item {
display: block;
}
.item:focus {
outline: 3px solid red;
}
<button>Go from here</button>
<div class="menu">
<a class="item" href="#">One</a>
<a class="item" href="#">Two</a>
<a class="item" href="#">Three</a>
</div>
If the cursor is over the menu, everything is tabbed back and forth fine. However, while the menu is hidden, it's not possible to focus none of the hidden elements with Tab. Is it possible to circumvent this?
Worth noting that I'd like it to work even in outdated browsers, so it's not a good idea to resort to modern solutions like :focus-within
(but a JS fallback might be okay; in very old or marginal browsers, nth-child
wouldn't work anyway and the menu would just be always expanded).