@page
| Version |
|---|
| CSS2 |
| IE8 | FF3.5 | SA4 | OP9.2+ | CH2 |
|---|---|---|---|---|
| None | None | None | Full | None |
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 | Chrome | ||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 5.5 | 6.0 | 7.0 | 8.0 | 1.0 | 1.5 | 2.0 | 3.0 | 3.5 | 1.3 | 2.0 | 3.1 | 4.0 | 9.2 | 9.5 | 10.0 | 2.0 |
| None | None | None | None | None | None | None | None | None | None | None | None | None | Full | Full | Full | None |
This at-rule is currently only supported by Opera 9.2 and later versions.