W3cubDocs

/Web APIs

CSSPageRule

CSSPageRule represents a single CSS @page rule.

CSSRule CSSGroupingRule CSSPageRule

Instance properties

Inherits properties from its ancestor CSSRule.

CSSPageRule.selectorText

Represents the text of the page selector associated with the at-rule.

CSSPageRule.style Read only

Returns the declaration block associated with the at-rule.

Instance methods

Inherits methods from its ancestor CSSRule.

Examples

The stylesheet includes a single @page rule, therefore the first (and only) rule returned will be a CSSPageRule.

css

@page {
  margin: 1cm;
}

js

let myRules = document.styleSheets[0].cssRules;
console.log(myRules[0]); // a CSSPageRule

Specifications

Browser compatibility

Desktop Mobile
Chrome Edge Firefox Internet Explorer Opera Safari WebView Android Chrome Android Firefox for Android Opera Android Safari on IOS Samsung Internet
CSSPageRule 1 12 19 9 ≤12.1 3 4.4 18 19 ≤12.1 1 1.0
selectorText 1 12 110 9 ≤12.1 3 4.4 18 110 ≤12.1 1 1.0
style 1 12 19 9 ≤12.1 3 4.4 18 19 ≤12.1 1 1.0

© 2005–2023 MDN contributors.
Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.
https://developer.mozilla.org/en-US/docs/Web/API/CSSPageRule