search

Home  >  Q&A  >  body text

How to add headers and footers to each page of a printed HTML document?

<p>Is it possible to print a custom header and footer HTML page on every printed page? </p> <p>I would like to add the words "UNCLASSIFIED" in red, Arial font, 16pt size, to the top and bottom of every printed page, regardless of content. </p> <p>To clarify, if the document is printed to 5 pages, each page should have custom headers and footers. </p> <p>Does anyone know if this can be achieved using HTML/CSS? </p>
P粉256487077P粉256487077510 days ago804

reply all(1)I'll reply

  • P粉950128819

    P粉9501288192023-08-21 00:55:15

    If you want to set the element you want to be a footer to position:fixed and bottom:0, when the page prints, it will repeat the element at the bottom of every printed page. For the header element, just set top:0.

    For example:

    <div class="divFooter">UNCLASSIFIED</div>

    CSS:

    @media screen {
      div.divFooter {
        display: none;
      }
    }
    @media print {
      div.divFooter {
        position: fixed;
        bottom: 0;
      }
    }

    reply
    0
  • Cancelreply