Jesse Rusak Jesse Rusak - 1 month ago 12
CSS Question

:active pseudo-class doesn't work in mobile safari

In Webkit on iPhone/iPad/iPod, specifying styling for an :active pseudo-class for an

<a>
tag doesn't trigger when you tap on the element. How can I get this to trigger? Example code:

<style>
a:active {
background-color: red;
}
</style>
<!-- snip -->
<a href="#">Click me</a>

Answer
<body ontouchstart="">
    ...
</body>

Applied just once, as opposed to every button element seemed to fix all buttons on the page. Alternatively you could use this small JS library called 'Fastclick'. It speed up click events on touch devices and takes care of this issue too.