Update: Thanks to explanations by Crowes and Boltclock below, I now have a clearer understanding that CSS pseudo-classes are explicitly stative (ie. describing an element's state in the present moment).
While there is a chronological dimension to javascript events, CSS pseudo-classes are, by contrast, either true in the present moment or false.
Consequently, unlike the javascript events they superficially resemble, CSS pseudo-classes do not (and cannot) refer back to the user's previous interactions with that element.
This makes my question largely redundant.
In 2017, it's a great surprise that while CSS has had :hover
for decades it still lacks that pseudo-class's most obvious complement - :click
.
I have searched Stackoverflow and in this Nov 2012 question:
Can I have an onclick effect in CSS?
The highest rated answer:
use
:active
is not a very good substitute for onclick
- if anything :active
is actually a substitute for onmousedown
.
The second highest rated answer -
use the checkbox hack
is not semantic (and... as hacks go, it feels pretty hacky).
So. Is there a minimum effort pure CSS replacement for javascript's onclick
?