CSS - @page

The @page CSS at-rule is used to modify some CSS properties when printing a document. You can't change all CSS properties with @page. You can only change the margins, orphans, widows, and page breaks of the document. Attempts to change any other CSS properties will be ignored.

Example

 

Please refer to the various pseudo-classes of @page for examples.

Syntax  

Descriptors

size
Specifies the target size and orientation of the page box’s containing block. In the general case, where one page box is rendered onto one page sheet, it also indicates the size of the destination page sheet.
marks
Adds crop and/or registration marks to the document.
bleed
Specifies the extent beyond the page box at which the page rendering is clipped.

Formal syntax

CSS
@page <page-selector-list> {
  <group-rule-body>
}

Description  

The @page CSS at-rule is used to modify some CSS properties when printing a document. You can't change all CSS properties with @page. You can only change the margins, orphans, widows, and page breaks of the document. Attempts to change any other CSS properties will be ignored.

The @page at-rule can be accessed via the CSS object model interface CSSPageRule.

Note: The W3C is discussing how to handle viewport-related <length> units, vh, vw, vmin, and vmax. Meanwhile do not use them within a @page at-rule.

Browser Compatibility  

Feature Chrome Firefox (Gecko) Internet Explorer Opera Safari
Basic support 2.0 19.0 (19.0) 8.0 6.0 No support
Feature Android Firefox Mobile (Gecko) IE Mobile Opera Mobile Safari Mobile
Basic support ? 19.0 (19.0) ? ? ?

Specifications  

Specification Status Comment
CSS Logical Properties Level 1
The definition of ':recto and :verso' in that specification.
Editor's Draft Adds the :recto and :verso page selectors
CSS Paged Media Module Level 3
The definition of '@page' in that specification.
Working Draft No change from CSS Level 2 (Revision 1), though more CSS at-rules can be used inside a @page.
CSS Level 2 (Revision 1)
The definition of '@page' in that specification.
Recommendation Initial definition

License

© 2016 Mozilla Contributors
Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.
https://developer.mozilla.org/en-us/docs/web/css/@page

At-rule CSS Layout NeedsMobileBrowserCompatibility Reference Web