Categories
CSS

How to disable browser print options (headers, footers, margins) from page with CSS?

Spread the love

To disable browser print options (headers, footers, margins) from page with CSSm we set the @page rule.

For instance, we write

<style type="text/css" media="print">
  @page {
    size: auto;
    margin: 0mm;
  }

  html {
    background-color: #ffffff;
    margin: 0px;
  }

  body {
    border: solid 1px blue;
    margin: 10mm 15mm 10mm 15mm;
  }
</style>

to set the margin to 0mm in the @page block to hide all the margins when printing.

By John Au-Yeung

Web developer specializing in React, Vue, and front end development.

Leave a Reply

Your email address will not be published. Required fields are marked *