The @page CSS at-rule is used to modify some CSS properties when printing a document.


@page {
  margin: 1cm;

@page :first {
  margin: 2cm;



Specifies the orientation of the document on the page, allowing it to be laid out and formatted as normal or be rotated to one either left or right side.


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.


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.

Formal syntax

@page <page-selector-list> {


@page pseudo-class examples

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


Unknown specification
# at-page-rule
Unknown specification
# page

Browser compatibility

BCD tables only load in the browser

See also