htmlcssprint-css

How to make page border in print CSS for every single page


I have a long HTML to print. Page is ready for printing but I need to border every single page. I added body { border:2px #666 solid; padding:5px; } in CSS code. HTML view is nice but print view is not. Because border-bottom is not showing first page and border-top is not showing all other pages.

I hope, I can explain what I want. I'm searched and still searching for solution. And I think it's easy trick. But stil not found.


Solution

  • Try this it will help you : It will make border on full screen.

        <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN">
    <html>
    <head>
      <title>Border around content</title>
      <style type="text/css">
        * {
          margin: 0;
          padding: 0;
        }
    
        html, body {
          height: 100%;
          overflow: hidden;
        }
    
        #wrapper {
          position: absolute;
          overflow: auto;
          left: 0;
          right: 0;
          top: 0;
          bottom: 0;
          border: 5px solid red;
        }
      </style>
    </head>
    <body>
      <div id="wrapper">
      </div>
    </body>
    </html>