Skip to: content, navigation

@page

Spec
Version
CSS2
Browser support (more…)
IE7 FF2 SA3 OP9.2+
None None None Full

Syntax

@page  [ { :left | :right | :first } ]  {
margin ruleset
}

Description

You can use the @page at-rule to specify margin values for the page box in style sheets for paged media such as the print media type.

In its simplest form, the at-rule is followed by a block of margin declarations:

@page {
  margin: 1in 1.5in;
}

You can specify different margins for all left-hand pages, all right-hand pages, or for the first page, by inserting a page selector between the at-rule and the block. The page selector is one of three pseudo-classes. Let’s look at an example that shows how these pseudo-classes can be used:

@page {
  margin: 2.5cm; /* default for all pages */
}

@page :left {
  margin-left: 5cm; /* left pages only */
}

@page :right {
  margin-right: 5cm; /* right pages only */
}

@page :first {
  margin-top: 8cm; /* extra top margin on the first page */
}

Example

This example sets default page margins:

@page {
  margin: 1in 1.5in;
}

Compatibility

Internet Explorer Firefox Safari Opera
5.5 6.0 7.0 1.0 1.5 2.0 1.3 2.0 3.0 9.2 9.5
None None None None None None None None None Full Full

This at-rule is currently only supported by Opera 9.2 and later versions.

User-contributed notes

Add a note

To post a note on this topic, please log in with your SitePoint username and password. If you don't have an account yet, you can create a new account for free.

Related Products

Search