Terjemahan ini belum lengkap. Mohon bantu menerjemahkan artikel ini dari Bahasa Inggris.

Aturan CSS @page digunakan untuk memodifikasi beberapa properti css ketika mencetak dokumen. Anda tidak dapat mengubah semua properti CSS dengan @page. Anda hanya dapat mengubah margin, orphans, widows, dan potongan halaman dari document. Usaha untuk mengubah properti CSS selain itu akan diabaikan.

 

@page {
  margin: 1cm;
}

@page :first {
  margin: 2cm;
}

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.

Syntax

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.

Formal syntax

@page <page-selector-list> {
  <page-body>
}

where
<page-selector-list> = [ <page-selector># ]?
<page-body> = <declaration>? [ ; <page-body> ]? | <page-margin-box> <page-body>

where
<page-selector> = <pseudo-page>+ | <ident> <pseudo-page>*
<page-margin-box> = <page-margin-box-type> { <declaration-list> }

where
<pseudo-page> = : [ left | right | first | blank ]
<page-margin-box-type> = @top-left-corner | @top-left | @top-center | @top-right | @top-right-corner | @bottom-left-corner | @bottom-left | @bottom-center | @bottom-right | @bottom-right-corner | @left-top | @left-middle | @left-bottom | @right-top | @right-middle | @right-bottom

Examples

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

Specifications

Specification Status Comment
CSS Logical Properties Level 1
The definition of ':recto and :verso' in that specification.
Editor's Draft Adds the :recto and :verso page selectors
CSS Paged Media Module Level 3
The definition of '@page' in that specification.
Working Draft No change from CSS Level 2 (Revision 1), though more CSS at-rules can be used inside a @page.
CSS Level 2 (Revision 1)
The definition of '@page' in that specification.
Recommendation Initial definition

Browser compatibility

Feature Chrome Edge Firefox (Gecko) Internet Explorer Opera Safari
Basic support 2.0 (Yes) 19.0 (19.0) 8.0 6.0 No support
Feature Android Edge Firefox Mobile (Gecko) IE Mobile Opera Mobile Safari Mobile
Basic support ? (Yes) 19.0 (19.0) ? ? ?

Tag Dokumen dan Kontributor

 Kontributor untuk laman ini: matthelosh
 Terakhir diperbarui oleh: matthelosh,