Possible to make a:after/before pseudo elements clickable as part of the link?

It looks like you have discovered a bug in the browser you are using.

Based on the spec, the generated content should be treated as a child of the element it is being generated for. I created a JSFiddle to test this out, and the generated text is linked for me in most browsers (Chrome 13 being the solitary exception.) My guess is that you are testing in Chrome. This is a reproducible bug.

The workaround is to simply specify a background color on your links ... if you want to be able to use this for all links, declaring a background image (but not specifying an image, or using a transparent .gif - or as just pointed out, setting opacity to anything other than 1) works.


I've had the same problem and apparently if I set

a { vertical-align: middle; }

(thus on the link itself, not the pseudo element), it works.


Just add this to your css:

a {padding-right:Ypx} /* Y = size of your url in pixels */

If the size of the URL varies you will have to use javascript to get it.