Browse By Name
HTMLCSSJavaScriptAppendix
You are here: Reference > CSS > at-rules > page

@page rule

A A Font size Print Content Add new content Share Share
Browser support:
Allows to define attributes for the page in paged media, such as print previews and printed pages.
Note: The @page rule is supported but not implemented in Internet Explorer.

The @page rule specifies the margins and dimensions of the printed pages.
If you want to get a @page rule dynamically, use the rules collection in Opera, and the pages collection in Internet Explorer. In Firefox and Safari, the rules collection is supported but does not contain the @page rules.

Syntax:

@page [pageSelector ] {
rules
}
pageSelector - Optional. Selector to specific pages.
rules - Style rules.

Page selectors:

:first Specifies that the rules apply to the first page.
:left Specifies that the rules apply to left pages.
:right Specifies that the rules apply to right pages.

Available style properties within the @page rule:

margin Specifies all four margins of the page box.
margin-bottom Specifies the bottom margin of the page box.
margin-left Specifies the left margin of the page box.
margin-right Specifies the right margin of the page box.
margin-top Specifies the top margin of the page box.
marks Specifies the size and orientation of the page box. No current browser supports it.
size Specifies whether cross marks or crop marks or both should be rendered outside the page box. Only Opera implemented it (buggily).

Examples:

    /* Sets all margins to 3cm. */
@page {
    margin: 3cm;
}
Did you find this example helpful? yes no


    /* Sets margins for right pages. */
@page :right {
    margin-left: 2cm;
    margin-right: 3cm;
}
Did you find this example helpful? yes no

External links:

User Contributed Comments

Post Content

Post Content