views:

238

answers:

4

Hi all,

Is there any way to remove header and footer of a html page, so that if user print it, there is no header and footer.

User can choose to remove it using print setup, but i wondering is there any css or javascript to remove it programatically?

thank you for any response.

+3  A: 

For the css used for printing only use this declaration:

<link rel="stylesheet" type="text/css" href="print.css" media="print" />

and in your print.css

#yourheader { display:none }
#yourfooter { display:none }
Gregoire
-1 - I think the poster is referring to the browsers header and footer not the page content.
RoToRa
@RoToRa : so the question is not clear, not the answer
Gregoire
I found the part "User can choose to remove it using print setup" quite obvious...
RoToRa
+1  A: 

You can do like:

   @media print
   {
      .noprint { display: none; }
   }

Now you can apply the noprint class to element you want to hide in printing.

Sarfraz
This class name sounds a bit too much like `.bold-red` to me. I see hiding from the printer as more of a presentational thing than a semantical thing.
Matti Virkkunen
+1  A: 

You seem to be referring to the header and footer lines that the browser is adding and not contents of the printed page. In that case the answer is: No, you can only change it in the settings.

RoToRa
+1  A: 

Hi all,

I do some googling and everybody said: "Can't remove them!" except using ActiveX and 3rd party plugins.

I wonder why some reporting controls (Telerik Reporting, DevX,...) can hide Header & Footer without using ActiveX or plugins! Are they print the page in another ways? What way?

Vinh