The reason it doesn't work in other browsers is due to the css focus specification. It states:
Class pseudo-class: applied when the element has focus (accepts keyboard events or other forms of text input).
Thus, it works great with text input fields or when focusing using the tab key. To make it compatible with other browsers above, add the tabindex attribute to each element, and this seems to fix the problem.
HTML:
<ul> <li id = 'product_types'><a href='#' tabindex="1">First</a></li> <li id = 'product_types'><a href='#' tabindex="2">Second</a></li> </ul>
CSS
#product_types { background-color: #B0B0B0; position: relative; } #product_types a:focus { background-color:yellow; }
JSFiddle example
source share