Skip to content

Instantly share code, notes, and snippets.

@chriseppstein
Created May 10, 2011 22:25
Show Gist options
  • Save chriseppstein/965507 to your computer and use it in GitHub Desktop.
Save chriseppstein/965507 to your computer and use it in GitHub Desktop.
<style media="print">
#printed-image { content: url(/path/to/image.png); }
</style>
<img id="printed-image" src="/images/spacer.gif">
@sxtxixtxcxh
Copy link

bonus: you can use this with google analytic's tracking gif, just be sure you set query string params correctly in your stylesheet.

@barraponto
Copy link

does this mean you need to have non-semantic markup in your tempaltes?

@chriseppstein
Copy link
Author

@sxtxixtxcxh That's pretty damn smart.

@barraponto I don't see why this would force non-semantic markup.

@barraponto
Copy link

that img tag, in most browsers, will display a gif which means nothing at all. right? can it be done with any other selector, like selecting a paragraph or a div and use :after to place the content?

@chriseppstein
Copy link
Author

@barraponto: I think it can. I used an img to be sure the browser would print it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment