CSS: printing URLs with generated content

A couple of months ago I wrote this post that showed how to display link URLs in print with the aid of JavaScript. Honestly speaking, I hate to use JavaScript when the same thing can be actually done with CSS. However, at the time of that post IE 6 and 7 got a still significant market share. But now, as Brian Adams sings, times are changing and IE 8 is gaining its momentum among the various IE machines.

IE 8 actually supports CSS generated content, so it's possible to display link URLs in print only with these few lines of code:

@media print {

    a[href]:after {

        content: ' (' attr(href) ') ';



Is that all? Actually, yes! Anyway, if your primary concern is still supporting old dinosaurs like IE 6 and 7, then my previous post will probably fit your needs.

This entry was posted in by Gabriele Romanato. Bookmark the permalink.

2 thoughts on “CSS: printing URLs with generated content”

Leave a Reply

Note: Only a member of this blog may post a comment.