views:

43

answers:

2

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>
+1  A: 

Add an event handler for ontouchstart in your <a> tag. This causes the CSS to magically work.

<a ontouchstart="">Click me</a>
Jesse Rusak
+1  A: 

Are you using all of the pseudoelemets or just the one? If you're using at least two, make sure they're in the right order or they all break:

a:link
a:visited
a:hover
a:active

..in that order. Also, If you're just using :active, add a:link, even if you're not styling it.

tahdhaze09