S
S
Svyatoslav Khusamov2016-05-24 15:20:38
css
Svyatoslav Khusamov, 2016-05-24 15:20:38

How to print from a browser without borders?

Google Chrome adds some fields when printing. As a result, the page close to the edges cannot be printed. This is not so critical on A4 paper, but fatal for a label printer, where the paper size is known to be small.
Even removing the indentation doesn't help:

<html>
  <head>
    <style>
      body {
        padding: 0;
        margin: 0; 
      }
    </style>
  </head>
  <body>
    Текст на странице
  </body>
</html>

Negative indents work, but the text is cut off, that is, the margins still remain, and the info is cut off.
The question is what to do if you want to print without margins???

Answer the question

In order to leave comments, you need to log in

3 answer(s)
S
Svyatoslav Khusamov, 2016-05-24
@khusamov

Wow, I found a solution:

<html>
  <head>
    <style>
      @media print { 
        @page {
          padding: 0;
          margin: 0; 
        }
      }
    </style>
  </head>
  <body>
    Текст на странице
  </body>
</html>

N
Nikita Kit, 2016-05-24
@ShadowOfCasper

the bottom line is that for printing html, separate styles should be specified. those are written in a special media query. It is called, as you might guess, print.
That is
(sabaka) media print {
and here you are already pointing to the elements, you remove the indents for them
}

S
Sergey Goryachev, 2016-05-24
@webirus

These are browser settings, not your page.
You can only use media print, but that won't get rid of the margins.
8bf295cecbb6456baa4ecee56b5495cd.png

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question