CSS-only double-click

Did you know it was possible to mimic the double-click behaviour in CSS? The only ingredients you need are some <a> tags that block the first click.

I've used <a> tags with a tabindex because these where the only elements that are stylable in all browsers. Thanks Chris Rebert for the reseach about click and focus behavior across browsers & OSes . The href is removed to prevent navigation or page jumps (with #-links).

As Don Caviness pointed out , Edge seem to behave a bit strange. It only works if you click - move the cursor a bit - and click again.

If you want to find out how it works, you can set $debug: true; to enable debug mode.

1. Double-click link

This link to google can only be opened by double clicking it.

2. Double-click video

Double-click to play or pause the video.

Thanks Amine Atallah for providing this hosted video.

3. Double-click youtube video

Double-click to play or pause the video. I've disabled the fullscreen mode, but if you enable this, the video will open fullscreen when you doubleclick it. Add the allowfullscreen attribute in this codepen to see this in action.

4. Double-click to change text color of another element

This example may look very familiar if you've seen my pen with stuff you can do with CSS pointer events , but this example doesn't use the pointer-events property but the :focus-within pseudo class. Not supported in IE & Edge at this moment ( view supported browsers ).

100%x180
Card 2

This text changes color if the button in card 1 is double-clicked.

That's all folks!

xoxo,
@Martijn_Cuppens

PS. make sure to check out RFS to control your responsive font sizes.