Search code examples
htmlcssfocusaccessibility

Is it possible select submenu with [Tab] key only? (css only)


Is it possible select (activate) submenu in ul/ol-styled menu with [Tab] key only, so the submenu will be visible?

I tried using :focus pseudo-class

ul
    li
        a:focus
        +
        ul
            li
                a ...

and with submenu selected:

ul
    li
        a (?)
        +
        ul
            li
                a:focus ...

But I can't select active node with CSS

Check this: http://jsfiddle.net/iegik/DKvH2/


Solution

  • If you want the complete submenue to be visible when a submenue-item has focus, I don't see a way without Javascript. If it is enough for you, if just the focused element is visible, you could try something like this:

    .links > li:not(:hover) li a:focus {
        left: 9999em;
        position: relative;
    }
    

    This would move the focused element back where it should be, if this didn't already happen via :hover-pseudo-class.

    http://jsfiddle.net/DKvH2/1/