Welcome to WebmasterWorld Guest from

Forum Moderators: not2easy

Message Too Old, No Replies

Printing web images

4:11 am on Jul 11, 2007 (gmt 0)

New User

10+ Year Member

joined:Nov 9, 2006
votes: 2

How's the best way to print a specific image from a web page? I have this code so far:

<link rel="stylesheet" href="print.css"
type="text/css" media="print" /> in the head section

and a css file with:

body {visibility:hidden;}
.print {visibility:visible;}

I then assigned class="print" to the image, but the entire page still prints.

4:18 am on July 11, 2007 (gmt 0)

Senior Member from US 

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month

joined:Sept 4, 2001
votes: 100


If I understand correctly, you want to pull one specific image from a page and print it without printing any other images or text.

There are two ways that come to mind. Have the image open in a new window with a normal link saying in effect "click here to print image", or use a script to pull the specific image.

I have a script for pulling elements off a page based on id which you are welcome to. Let me know and I will post it.


I forgot that I posted the script once before. It's at [webmasterworld.com...]

[edited by: Marshall at 4:34 am (utc) on July 11, 2007]

Mod Edit: fixed link

[edited by: limbo at 11:19 am (utc) on July 11, 2007]

12:56 pm on July 11, 2007 (gmt 0)

Full Member

10+ Year Member

joined:Apr 9, 2004
votes: 0

Perhaps if you assign "visibility:hidden" to any <DIV> tags or other elements in the page instead of assigning it to the <body> tag.

For example, you could assign a DIV to each element of the page with a class name of "no_print" and then put the following in your stylesheet:

.no_print {visibility:hidden;}

Kind of clunky, but I think you get the idea.

Or if you already have class names assigned for your "media=screen" CSS file, I would suggest using those names in your print.css file to assign the visibility to, again instead of declaring the <body> tag to be hidden.

I guess it really depends on how much you have going on these pages.

3:57 pm on July 11, 2007 (gmt 0)

New User

10+ Year Member

joined:Nov 9, 2006
votes: 2

thanks, I will look at these options