Skip to content

iOS Safari & :active

Published: October 7, 2024

1 min read


iOS Safari & :active

All I wanted was for a div to visually respond when tapped - simple, right? But nope, Safari on iOS had other plans. The fix? Add ontouchstart="" to your component or, even worse, directly to your html element.

Captain America sighing in frustration

That’s right, a completely empty inline JavaScript event just to get Safari to acknowledge a basic CSS behavior. It's almost as if someone at Apple thought -"Ohh no, no, no, why make things simpler when we can force developers to add pointless hacks?"

And what's with the -webkit-* vendor prefix fuckery!?

And guess where I unearthed this solution? On a 14-year-old Stack Overflow thread 🙂.
Yes, a fix from over a decade ago is still what I had to rely on today.

Meanwhile, every other modern browser is perfectly content letting :active do its job.
But Safari? It prefers to keep things... nostalgic. Guess it's missing IE.

Darshan Pandya