--- title: '@page' slug: Web/CSS/@page tags: - '@page' - At-rule - CSS - Layout - NeedsTranslation - Reference - TopicStub - Web translation_of: Web/CSS/@page ---
{{CSSRef}}

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

Syntax

@page {
  margin: 1cm;
}

@page :first {
  margin: 2cm;
}

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.

Description

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 {{domxref("CSSPageRule")}}.

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

Formal syntax

{{csssyntax}}

Examples

@page pseudo-class examples

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

Specifications

Specification Status Comment
{{SpecName('CSS Logical Properties', '#page', ':recto and :verso')}} {{Spec2('CSS Logical Properties')}} Adds the :recto and :verso page selectors
{{SpecName('CSS3 Paged Media', '#at-page-rule', '@page')}} {{Spec2('CSS3 Paged Media')}} No change from {{SpecName('CSS2.1')}}, though more CSS at-rules can be used inside a @page.
{{SpecName('CSS2.1', 'page.html#page-selectors', '@page')}} {{Spec2('CSS2.1')}} Initial definition

Browser compatibility

{{Compat("css.at-rules.page")}}

See also