Robert Asaad
Robert Asaad

Reputation: 45

On mobile, how do I style a hyperlink when it's tapped?

I'm trying to style a hyperlink's state when it's tapped on a mobile device. Basically it has to flicker a green color right after being tapped. I've tried all the CSS pseudoclasses for hyperlink states, including:

a:active

a:hover

a:focus

But on my iPhone, the hyperlink doesn't show the intended style when tapped. Is there a better way through CSS or jQuery to accomplish this?

Upvotes: 2

Views: 172

Answers (1)

cssyphus
cssyphus

Reputation: 40038

You might need to use a hack along with :active

Try adding this event handler to the <body> tag:

<body ontouchstart="">

Reference

Upvotes: 2

Related Questions