This is how XKCD What If? does reference links, as seen on https://what-if.xkcd.com/130/. The code is directly copied from their site, so you should probably change it.
The tooltip works best if the text is short. You can insert links in the tooltip.