0

JSFiddle (The *:focus rule is to illustrate which element is marked as having focus.)

What I'm wondering is why, when I click a menu item, it gets the focus... but clicking a menu item does not give it focus.

What's wrong with the CSS to make it behave this way?

Niet the Dark Absol
  • 320,036
  • 81
  • 464
  • 592
  • What you describe only works that way in Internet Explorer.. (*so i would not rely on it..*). FF and Chrome do **not** give focus on the `div` when clicked.. – Gabriele Petrioli Oct 29 '12 at 23:58

2 Answers2

0

focus is generally only for elements that can receive keyboard or other input, so by this heuristic lis don't qualify. This question has more about it..

In the specs, CSS doesn't explicitly define what elements can be in those states, so it's hard to come up with a set rule for what can and can't be set to focus.

What might work for your purposes is active, which you can view here.

Community
  • 1
  • 1
jamesplease
  • 12,547
  • 6
  • 47
  • 73
  • But `onkeydown` events will fire on the `
  • `... And that doesn't explain why `
    ` is okay. Nor does it explain why if I wrap the content of the `
  • ` with `
    ` tags, it still doesn't accept focus.
– Niet the Dark Absol Oct 29 '12 at 23:54