amit
amit

Reputation: 2331

How to control page margin when printing HTML document?

I'm printing a long HTML document and i want to set the margin between the pages in the CSS file. Unfortunately, the padding/margin only take effect in the first page (padding-top) and the last page (padding-bottom).

Any way to set the margin between pages?

Upvotes: 4

Views: 6545

Answers (1)

Adriano Repetti
Adriano Repetti

Reputation: 67080

It's not margin between pages but page margin. It's controlled by a specific CSS media @page:

@page {
    margin: 1cm;
}

Please refer to linked specs for all the details (especially about how @page combines with, for example, <body> margins).

Note that with pseudo-selectors you can control the aspect of :left, :right and :first pages (just to mention few common use cases).

Upvotes: 6

Related Questions