I had some CSS like this:
a {
display: block
}
a:focus {
background: #000
}
And an anchor like this:
<a href="">Hi!</a>
why can’t I focus on it by clicking? I know it redirects but one would assume for a split second the background would go black. Whats up?
Not all browsers give elements focus when clicked. I believe Internet Explorer does, but Google Chrome certainly doesn’t. If you’re looking to apply a style when the mouse is down on the element, consider
:activeinstead:You can compare the two live here. On this page, Tab once and the first one should get the focus and the border.