how to remove header and footer in printing using javascript?

Rate this post

Today, We want to share with you how to remove header and footer in printing using javascript.In this post we will show you set header/footer print javascript, hear for browser print header/footer javascript we will give you demo and example for implement.In this post, we will learn about How To Add Header And Footer In PDF Page Using DOMPDF? with an example.

remove header/footer print javascript

Example 1:

@page { margin: 0; }

OR

@media print {
  @page { margin: 0; }
  body { margin: 1.6cm; }
}

Example 2:

<style type="text/css" media="print">
    @page 
    {
        size: auto;   /* auto is the default value */
        margin: 0mm;  /* this small affects the margin in the printer some imp settings */
    }
</style>

Free Live Chat for Any Issue

remove header and footer while printing Example

index.html

<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <title>Print To My Web WWW.pakainfo.com</title>
    <style type="text/css" media="print">
        @page 
        {
            size: auto;   /* auto is the main current active printer page size */
            margin: 0mm;  /* this small affects the margin in the printer IMP settings */
        }

        body 
        {
            background-color:#FFFFFF; 
            border: solid 1px black ;
            margin: 0px;  /* the margin style on the data content before printing */
       }
    </style>
</head>
<body>
  <div>Welcome Page</div>
  <div>Tamilrokers new link</div>
</body>
</html>

How to Remove URL from Printing the Page ?

simplest ways

@page { 
	size: auto; 
	margin: 0; 
} 


OR
@print { 
	@page :footer { 
		display: none
	} 

	@page :header { 
		display: none
	} 
} 

@media print { 
	@page { 
		margin-top: 0; 
		margin-bottom: 0; 
	} 
	body { 
		padding-top: 72px; 
		padding-bottom: 72px ; 
	} 
} 

Download

I hope you get an idea about remove the default browser header and footer when printing html.
I would like to have feedback on my infinityknow.com blog.
Your valuable feedback, question, or comments about this article are always welcome.
If you enjoyed and liked this post, don’t forget to share.