Search code examples
csscss-selectorspseudo-class

using :focus pseudo class on li or other element else than a,input,button, etc


Is it possible to select an element that is focused, like a:focus or input:focus, but on the other element, such as div, li, span or else?

If it's not possible, how can it be substituted with a tag? I am trying to modify height of a li element when it's focused, tried with a, but the height won't change.


Requested Info :

"Can you also explain how do you put focus on LI?"

Via css selector li:focus. See https://jsfiddle.net/s4nji/Rjqy5/.


Solution

  • That's simple: just add a tabindex attribute to the elements which normally don't receive focus.