Hector Minaya
Hector Minaya

Reputation: 1705

How do I print a header on every page using CSS or JavaScript/jQuery

I have a page where there is a lot of text, probably 15 pages, I wan't to be able to add a header at the begining of every page when the user prints the document.

Is this possible with CSS or JavaScript/jQuery????

Upvotes: 2

Views: 2224

Answers (2)

Boris Guéry
Boris Guéry

Reputation: 47614

You can use classic CSS by targeting media using media attribute.

Example:

<link rel="stylesheet" type="text/css" media="all" href="all.css" />
<link rel="stylesheet" type="text/css" media="print" href="print.css" />

Add your <header></header> in your page, position it with CSS, if you don't want it to be included in a browser do:

header {
  display: none;
}

in your all.css

And in your print.css:

header {
  display: block;
}

Upvotes: 5

Rui Jiang
Rui Jiang

Reputation: 1672

Print layouts change depending on the browser, default fonts installed, and any other custom settings used. How would you know where the page divisions are?

Your best bet may be to produce a PDF of your documentation.

Upvotes: 1

Related Questions